diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f86b175..e2a2f70cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,52 @@ # Changelog +## 42.1.0 [#1273](https://github.com/openfisca/openfisca-core/pull/1273) + +#### New features + +- Introduce `indexed_enums.EnumType` + - Allows for actually fancy indexing `indexed_enums.Enum` + +#### Technical changes + +- Fix doctests + - Now `pytest openfisca_core/indexed_enums` runs without errors +- Fix bug in `Enum.encode` when passing a scalar + - Still raises `TypeError` but with an explanation of why it fails +- Fix bug in `Enum.encode` when encoding values not present in the enum + - When encoding values not present in an enum, `Enum.encode` always encoded + the first item of the enum + - Now, it correctly encodes only the values requested that exist in the enum + +##### Before + +```python +from openfisca_core import indexed_enums as enum + +class TestEnum(enum.Enum): + ONE = "one" + TWO = "two" + +TestEnum.encode([2]) +# EnumArray([0]) +``` + +##### After + +```python +from openfisca_core import indexed_enums as enum + +class TestEnum(enum.Enum): + ONE = "one" + TWO = "two" + +TestEnum.encode([2]) +# EnumArray([]) + +TestEnum.encode([0,1,2,5]) +# EnumArray([ ]) +``` + ### 42.0.8 [#1272](https://github.com/openfisca/openfisca-core/pull/1272) #### Documentation diff --git a/openfisca_core/indexed_enums/_enum_type.py b/openfisca_core/indexed_enums/_enum_type.py index 777d611ba..fe098e2c7 100644 --- a/openfisca_core/indexed_enums/_enum_type.py +++ b/openfisca_core/indexed_enums/_enum_type.py @@ -111,3 +111,6 @@ def __new__( def __dir__(cls) -> list[str]: return sorted({"items", "indices", "names", "enums", *super().__dir__()}) + + +__all__ = ["EnumType"] diff --git a/setup.py b/setup.py index 491479ccb..8cdaa6173 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,7 @@ setup( name="OpenFisca-Core", - version="42.0.8", + version="42.1.0", author="OpenFisca Team", author_email="contact@openfisca.org", classifiers=[