MCPcopy Create free account
hub / github.com/PyTables/PyTables / __init__

Method __init__

tables/atom.py:1118–1146  ·  view source on GitHub ↗
(
        self, enum: Enum | Any, dflt: Any, base: Atom | str, shape: Shape = ()
    )

Source from the content-addressed store, hash-verified

1116 )
1117
1118 def __init__(
1119 self, enum: Enum | Any, dflt: Any, base: Atom | str, shape: Shape = ()
1120 ) -> None:
1121 if not isinstance(enum, Enum):
1122 enum = Enum(enum)
1123 self.enum = enum
1124
1125 if isinstance(base, str):
1126 base = Atom.from_type(base)
1127
1128 self._checkbase(base)
1129 self.base = base
1130 assert isinstance(self.base, Atom)
1131
1132 default = enum[dflt] # check default value
1133 self._defname = dflt # kept for representation purposes
1134
1135 # These are kept to ease dumping this particular
1136 # representation of the enumeration to storage.
1137 names, values = [], []
1138 for name, value in enum:
1139 names.append(name)
1140 values.append(value)
1141 basedtype = self.base.dtype
1142
1143 self._names = names
1144 self._values = np.array(values, dtype=basedtype.base)
1145
1146 Atom.__init__(self, basedtype, shape, default)
1147
1148 def __repr__(self) -> str:
1149 return "EnumAtom(enum={!r}, dflt={!r}, base={!r}, shape={!r})".format(

Callers

nothing calls this directly

Calls 5

_checkbaseMethod · 0.95
EnumClass · 0.85
from_typeMethod · 0.45
appendMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected