Skip to content

Commit

Permalink
Fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Sep 13, 2021
1 parent a06c0c6 commit 6f973ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions openfisca_core/indexed_enums/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ def __init__(self, name: str) -> None:

@classmethod
def encode(cls, array: Encodable) -> EnumArray:
"""Encodes an :class:`.Encodable` array into an :class:`.EnumArray.`
"""Encodes an encodable array into an :obj:`.EnumArray`.
Args:
array: Array to encode.
Returns:
An array with the encoded input values.
:obj:`.EnumArray`: An :obj:`array <.EnumArray>` with the encoded
input values.
Examples:
>>> class MyEnum(Enum):
Expand All @@ -113,28 +114,28 @@ def encode(cls, array: Encodable) -> EnumArray:
>>> MyEnum.encode(enum_array)
EnumArray([<MyEnum.bar: b'bar'>])
# ArrayLike["Enum"]
# ArrayTipe[Enum]
>>> array = numpy.array([MyEnum.bar])
>>> enum_array = MyEnum.encode(array)
>>> enum_array[0] == MyEnum.bar.index
True
# ArrayLike[bytes]
# ArrayType[bytes]
>>> array = numpy.array([b"bar"])
>>> enum_array = MyEnum.encode(array)
>>> enum_array[0] == MyEnum.bar.index
True
# ArrayLike[int]
# ArrayType[int]
>>> array = numpy.array([1])
>>> enum_array = MyEnum.encode(array)
>>> enum_array[0] == MyEnum.bar.index
True
# ArrayLike[str]
# ArrayType[str]
>>> array = numpy.array(["bar"])
>>> enum_array = MyEnum.encode(array)
Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/indexed_enums/enum_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EnumArray(numpy.ndarray):
Note:
Subclassing `numpy.ndarray` is a little tricky™. To read more about the
:meth:`.__new__` and `.__array_finalize__` methods below, see
:meth:`.__new__` and :meth:`.__array_finalize__` methods below, see
`Subclassing ndarray`_.
Examples:
Expand Down

0 comments on commit 6f973ca

Please sign in to comment.