Skip to content

Commit a3dbd94

Browse files
author
Mauko Quiroga
committed
Add missing doc to enum init
1 parent 397892e commit a3dbd94

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

openfisca_core/indexed_enums/enum.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ def __init__(self, name: str) -> None:
6565
names of the previously initialized items, so its length is the index
6666
of this item.
6767
68+
Args:
69+
name: The name of the enum.
70+
71+
Examples:
72+
>>> MyEnum = Enum("MyEnum", "foo bar")
73+
>>> MyEnum.bar.index
74+
1
75+
76+
>>> class MyEnum(Enum):
77+
... foo = b"foo"
78+
... bar = b"bar"
79+
80+
>>> MyEnum.bar.index
81+
1
82+
6883
"""
6984

7085
self.index = len(self._member_names_)

openfisca_core/indexed_enums/enum_array.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __eq__(self, other: Any) -> Union[ArrayType[bool], bool]:
7676
Args:
7777
other: Another object to compare to.
7878
79+
Returns:
80+
True, False, or a boolean :class:`numpy.ndarray`.
81+
7982
Examples:
8083
>>> class MyEnum(enums.Enum):
8184
... foo = b"foo"
@@ -112,6 +115,9 @@ def __ne__(self, other: Any) -> Union[ArrayType[bool], bool]:
112115
Args:
113116
other: Another object to compare to.
114117
118+
Returns:
119+
True, False, or a boolean :class:`numpy.ndarray`.
120+
115121
Examples:
116122
>>> class MyEnum(enums.Enum):
117123
... foo = b"foo"
@@ -155,7 +161,10 @@ def _forbidden_operation(self, other: Any) -> NoReturn:
155161
__or__ = _forbidden_operation
156162

157163
def decode(self) -> ArrayType["enums.Enum"]:
158-
"""Return the enum items of the :obj:`.EnumArray`.
164+
"""Decodes itself to a normal array.
165+
166+
Returns:
167+
The enum items of the :obj:`.EnumArray`.
159168
160169
Examples:
161170
>>> class MyEnum(enums.Enum):
@@ -175,7 +184,10 @@ def decode(self) -> ArrayType["enums.Enum"]:
175184
)
176185

177186
def decode_to_str(self) -> ArrayType[str]:
178-
"""Return the string identifiers of the :obj:`.EnumArray`.
187+
"""Decodes itself to an array of strings.
188+
189+
Returns:
190+
The string identifiers of the :obj:`.EnumArray`.
179191
180192
Examples:
181193
>>> class MyEnum(enums.Enum):

0 commit comments

Comments
 (0)