Enum based on enum34, whose items have an index.
Encode a string numpy array, an enum item numpy array, or an int numpy
array into an EnumArray
. See EnumArray.decode
for
decoding.
array (numpy.ndarray) – Array of string identifiers, or of enum items, to encode.
An EnumArray
encoding the input array values.
For instance:
>>> string_identifier_array = asarray(['free_lodger', 'owner'])
>>> encoded_array = HousingOccupancyStatus.encode(string_identifier_array)
>>> encoded_array[0]
2 # Encoded value
>>> free_lodger = HousingOccupancyStatus.free_lodger
>>> owner = HousingOccupancyStatus.owner
>>> enum_item_array = asarray([free_lodger, owner])
>>> encoded_array = HousingOccupancyStatus.encode(enum_item_array)
>>> encoded_array[0]
2 # Encoded value
NumPy array subclass representing an array of enum items.
EnumArrays are encoded as int
arrays to improve performance
Return the array of enum items corresponding to self.
For instance:
>>> enum_array = household('housing_occupancy_status', period)
>>> enum_array[0]
>>> 2 # Encoded value
>>> enum_array.decode()[0]
<HousingOccupancyStatus.free_lodger: 'Free lodger'>
Decoded value: enum item