Skip to content

Commit

Permalink
Added a new elif condition to handle integer arrays. If the array's d…
Browse files Browse the repository at this point in the history
…ata type kind is "i" (signed integer) or "u" (unsigned integer), the indices variable is directly assigned the array value.

Updated the else condition to raise a ValueError only for unsupported array data types that are not handled by the previous conditions.
  • Loading branch information
MaxGhenis committed Apr 27, 2024
1 parent 6e9f962 commit 6803f6e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions policyengine_core/enums/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def encode(cls, array: Union[EnumArray, np.ndarray]) -> EnumArray:
[array == item for item in cls],
[item.index for item in cls],
)
elif array.dtype.kind in {"i", "u"}:
# Integer array
indices = array
else:
raise ValueError(f"Unsupported array dtype: {array.dtype}")

Expand Down

0 comments on commit 6803f6e

Please sign in to comment.