gemseo /
utils
base_enum module
Custom Enumerations.
The .BaseEnum class enables the specification of options which were previously defined
using class attributes. It enables backward compatibility, as the user can either provide
the Enum member or its name as a string. The conversion is then made implicitly.
-
class gemseo.utils.base_enum.BaseEnum(value)[source]
Bases: Enum
A base Enum class that can be compared to strings.
-
classmethod get_member_from_name(value)[source]
Return an Enum member from a name or a member.
This class method returns an Enum member
either from the name of the member or the member itself.
It enables backward compatibility with the use of class attributes
for options.
- Parameters:
value (str | BaseEnum) – An Enum member name or an Enum member.
- Raises:
TypeError – If the Enum member is not from the same Enum class.
- Return type:
BaseEnum
-
class gemseo.utils.base_enum.CallableEnum(value)[source]
Bases: BaseEnum
Enum whose value is callable.
-
class gemseo.utils.base_enum.CamelCaseEnum(value)[source]
Bases: Enum
Enum that are represented as the camel case of the key name.
-
class gemseo.utils.base_enum.MetaEnum(cls, bases, classdict, **kwds)[source]
Bases: EnumMeta
An enum metaclass to subclass the membership operator.
-
mro()
Return a type’s method resolution order.
-
gemseo.utils.base_enum.get_names(enumeration)[source]
Return the names of the members of an enumeration.
- Parameters:
enumeration (MetaEnum) – The enumeration of interest.
- Returns:
The names of the enumeration.
- Return type:
list[str]