Skip to content

Commit

Permalink
breaking change: remove retro-compatibility of indicator __getitem__
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Apr 24, 2024
1 parent 11175ae commit 3f462c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions xclim/core/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ def is_parameter_dict(cls, other: dict) -> bool:
cls.__dataclass_fields__.keys() # pylint: disable=no-member
)

def __getitem__(self, key) -> str:
"""Return an item in retro-compatible fashion."""
try:
return str(getattr(self, key))
except AttributeError as err:
raise KeyError(key) from err
# def __getitem__(self, key) -> str:
# """Return an item in retro-compatible fashion."""
# try:
# return str(getattr(self, key))
# except AttributeError as err:
# raise KeyError(key) from err

def __contains__(self, key) -> bool:
"""Imitate previous behaviour where "units" and "choices" were missing, instead of being "_empty"."""
Expand Down Expand Up @@ -455,7 +455,7 @@ def __new__(cls, **kwds): # noqa: C901
# parameters has already been update above.
kwds["compute"] = declare_units(
**{
inv_var_map[k]: m["units"]
inv_var_map[k]: m.units
for k, m in parameters.items()
if "units" in m and k in inv_var_map
}
Expand Down

0 comments on commit 3f462c9

Please sign in to comment.