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

Method from_type

tables/atom.py:393–418  ·  view source on GitHub ↗

Create an Atom from a PyTables type. Optional shape and default value may be specified as the shape and dflt arguments, respectively:: >>> Atom.from_type('bool') BoolAtom(shape=(), dflt=False) >>> Atom.from_type('int16', shape=(2, 2))

(
        cls, type_: str, shape: Shape = (), dflt: Any = None
    )

Source from the content-addressed store, hash-verified

391
392 @classmethod
393 def from_type(
394 cls, type_: str, shape: Shape = (), dflt: Any = None
395 ) -> Atom:
396 """Create an Atom from a PyTables type.
397
398 Optional shape and default value may be specified as the
399 shape and dflt arguments, respectively::
400
401 >>> Atom.from_type('bool')
402 BoolAtom(shape=(), dflt=False)
403 >>> Atom.from_type('int16', shape=(2, 2))
404 Int16Atom(shape=(2, 2), dflt=0)
405 >>> Atom.from_type('string40', dflt='hello')
406 Traceback (most recent call last):
407 ...
408 ValueError: unknown type: 'string40'
409 >>> Atom.from_type('Float64')
410 Traceback (most recent call last):
411 ...
412 ValueError: unknown type: 'Float64'
413
414 """
415 if type_ not in all_types:
416 raise ValueError(f"unknown type: {type_!r}")
417 kind, itemsize = split_type(type_)
418 return cls.from_kind(kind, itemsize, shape, dflt)
419
420 @classmethod
421 def from_kind(

Callers 8

from_dtypeMethod · 0.45
__init__Method · 0.45
populateFileMethod · 0.45
OldRecordClass · 0.45
populateFileMethod · 0.45
test04_maxFieldsMethod · 0.45
table-tree.pyFile · 0.45

Calls 2

split_typeFunction · 0.85
from_kindMethod · 0.45

Tested by 4

populateFileMethod · 0.36
populateFileMethod · 0.36
test04_maxFieldsMethod · 0.36