-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
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. |
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 }) |
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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
|
operator requires Python 3.9, which would then exclude Ubuntu 20.04 and other distros with older Python.