Skip to content

Commit

Permalink
Restore Python 3.8 compatibility for dictionary merge (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmenke authored and the-hampel committed Nov 13, 2023
1 parent 781dfaa commit 2e14b41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions python/solid_dmft/dmft_tools/matheval.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class MathExpr(object):
"max": max,
"pow": pow,
"round": round,
} | {key: value for (key, value) in vars(math).items() if not key.startswith("_")}
}
functions.update(
{key: value for (key, value) in vars(math).items() if not key.startswith("_")}
)

def __init__(self, expr):
if any(elem in expr for elem in "\n#"):
Expand All @@ -53,4 +56,4 @@ def __init__(self, expr):
self.code = compile(node, "<string>", "eval")

def __call__(self, **kwargs):
return eval(self.code, {"__builtins__": None}, self.functions | kwargs)
return eval(self.code, {"__builtins__": None}, {**self.functions, **kwargs})
8 changes: 4 additions & 4 deletions python/solid_dmft/dmft_tools/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
# *************************************

# call postprocessing
Expand All @@ -413,7 +413,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 })
# *************************************

# call postprocessing
Expand Down Expand Up @@ -587,7 +587,7 @@ def make_positive_definite(G):

# 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 })
# *************************************

# call postprocessing
Expand All @@ -604,7 +604,7 @@ def make_positive_definite(G):

# 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 })
# *************************************

# call postprocessing
Expand Down

0 comments on commit 2e14b41

Please sign in to comment.