Skip to content

Commit

Permalink
chore: version bump (fixes #1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Oct 9, 2024
1 parent 38f99e0 commit 380e3af
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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([<TestEnum.ONE: 'one'> <TestEnum.TWO: 'two'>])
```

### 42.0.8 [#1272](https://github.com/openfisca/openfisca-core/pull/1272)

#### Documentation
Expand Down
3 changes: 3 additions & 0 deletions openfisca_core/indexed_enums/_enum_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ def __new__(

def __dir__(cls) -> list[str]:
return sorted({"items", "indices", "names", "enums", *super().__dir__()})


__all__ = ["EnumType"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 380e3af

Please sign in to comment.