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

Function _abstract_atom_init

tables/atom.py:609–631  ·  view source on GitHub ↗

Return a constructor for an abstract `Atom` class.

(
    deftype: str, defvalue: Any
)

Source from the content-addressed store, hash-verified

607
608
609def _abstract_atom_init(
610 deftype: str, defvalue: Any
611) -> Callable[[Atom, int | None, Shape, Any], None]:
612 """Return a constructor for an abstract `Atom` class."""
613 defitemsize = split_type(deftype)[1]
614
615 def __init__( # noqa: N807
616 self: Atom,
617 itemsize: int | None = defitemsize,
618 shape: Shape = (),
619 dflt: Any = defvalue,
620 ) -> None:
621 assert self.kind in atom_map
622 try:
623 atomclass = atom_map[self.kind][itemsize]
624 except KeyError:
625 raise _invalid_itemsize_error(
626 self.kind, itemsize, atom_map[self.kind]
627 )
628 self.__class__ = atomclass
629 atomclass.__init__(self, shape, dflt)
630
631 return __init__
632
633
634class StringAtom(Atom): # type: ignore[misc]

Callers 4

IntAtomClass · 0.85
UIntAtomClass · 0.85
FloatAtomClass · 0.85
TimeAtomClass · 0.85

Calls 1

split_typeFunction · 0.85

Tested by

no test coverage detected