Skip to content

Commit

Permalink
fixed recursive error
Browse files Browse the repository at this point in the history
  • Loading branch information
santacodes committed Oct 4, 2024
1 parent 74879b4 commit faa78bc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pybamm/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,22 @@ def get_docstring(self, key):

def __getattribute__(self, name):
try:
return super().__getattribute__(name)
except AttributeError as error:
# For backwards compatibility, parameter sets that used to be defined in
# this file now return the name as a string, which will load the same
# parameter set as before when passed to `ParameterValues`
if name in self:
# Bypass the overloaded __getitem__ and __iter__ to avoid recursion
_all_entries = super().__getattribute__("_all_entries")
if name in _all_entries:
msg = (
f"Parameter sets should be called directly by their name ({name}), "
f"instead of via pybamm.parameter_sets (pybamm.parameter_sets.{name})."
)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return name
raise error
except AttributeError:
pass # Handle the attribute error normally

return super().__getattribute__(name)


#: Singleton Instance of :class:EntryPoint initialised with pybamm_parameter_sets"""
Expand Down

0 comments on commit faa78bc

Please sign in to comment.