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

Class ComplexAtom

tables/atom.py:845–887  ·  view source on GitHub ↗

Defines an atom of kind complex. Allowed item sizes are 8 (single precision) and 16 (double precision). This class must be used instead of more concrete ones to avoid confusions with numarray-like precision specifications used in PyTables 1.X.

Source from the content-addressed store, hash-verified

843
844
845class ComplexAtom(Atom):
846 """Defines an atom of kind complex.
847
848 Allowed item sizes are 8 (single precision) and 16 (double precision). This
849 class must be used instead of more concrete ones to avoid confusions with
850 numarray-like precision specifications used in PyTables 1.X.
851
852 """
853
854 # This definition is a little more complex (no pun intended)
855 # because, although the complex kind is a normal numerical one,
856 # the usage of bottom-level classes is artificially forbidden.
857 # Everything will be back to normality when people has stopped
858 # using the old bottom-level complex classes.
859
860 kind = "complex"
861 _deftype = "complex128"
862 _defvalue = 0j
863 _isizes = [8, 16]
864
865 @property # type: ignore[misc]
866 def itemsize(self) -> int: # type: ignore[override]
867 """Size in bytes of a sigle item in the atom."""
868 return self.dtype.base.itemsize
869
870 # Only instances have a `type` attribute, so complex types must be
871 # registered by hand.
872 all_types.add("complex64")
873 all_types.add("complex128")
874 if hasattr(np, "complex192"):
875 all_types.add("complex192")
876 _isizes.append(24)
877 if hasattr(np, "complex256"):
878 all_types.add("complex256")
879 _isizes.append(32)
880
881 def __init__(
882 self, itemsize: int, shape: Shape = (), dflt: Any = _defvalue
883 ) -> None:
884 if itemsize not in self._isizes:
885 raise _invalid_itemsize_error("complex", itemsize, self._isizes)
886 self.type = "%s%d" % (self.kind, itemsize * 8)
887 Atom.__init__(self, self.type, shape, dflt)
888
889
890class _ComplexErrorAtom(ComplexAtom, metaclass=type):

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected