Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore Python 3.8 compatibility for dictionary merge #63

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

hmenke
Copy link
Member

@hmenke hmenke commented Nov 9, 2023

The | operator requires Python 3.9, which would then exclude Ubuntu 20.04 and other distros with older Python.

@the-hampel
Copy link
Member

Are we sure we are not using any other Python 3.9 features already? @merkelm @alberto-carta Otherwise we can of course restore backward compatibility. TRIQS itself states 3.6, but I think some parts require newer Python versions.

@hmenke
Copy link
Member Author

hmenke commented Nov 9, 2023

I've been using solid_dmft on Ubuntu 20.04 which has Python 3.8. Unfortuantely I developed #61 on a machine with Python 3.10 and the CI also runs Python 3.10, so I did not notice the compatibility problem.

@@ -397,7 +397,7 @@ def solve(self, **kwargs):

# Solve the impurity problem for icrsh shell
# *************************************
self.triqs_solver.solve(h_int=self.h_int, **(self.solver_params | random_seed ))
self.triqs_solver.solve(h_int=self.h_int, **{ **self.solver_params, **random_seed })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be an option to just store the keyword directly in line 352 in self.solver_params , i.e.:

self.solver_params['random_seed'] = int(self.random_seed_generator(it=kwargs["it"], rank=mpi.rank))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not overwrite solver_params['random_seed'] in-place, because that should be the value from read_config and if you overwrite this the wrong value might be serialized to the output file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the original solver_params that are stored in the h5 are owned by dmft_cylce, and stored from there to the h5, the dict withing the solid_dmft solver object is not used for storage. Or do you mean other output? I think that should be save to overwrite then no? At least I do not see a problem right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictionaries (and lists) are reference types. They are not copied (unless explicitly using .copy()):

>>> a = { "foo": 1 }
>>> b = a
>>> b["foo"] = 2
>>> a
{'foo': 2}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes of course. Somehow I wasn't sure with a dict but you are of course right. Then we do not want to change it ;-)

@the-hampel the-hampel merged commit 22e3125 into TRIQS:unstable Nov 9, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants