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

Method __init__

tables/nodes/filenode.py:577–615  ·  view source on GitHub ↗
(self, node, h5file, **kwargs)

Source from the content-addressed store, hash-verified

575 ]
576
577 def __init__(self, node, h5file, **kwargs):
578 if node is not None:
579 # Open an existing node and get its version.
580 self._check_attributes(node)
581 self._version = node.attrs.NODE_TYPE_VERSION
582 elif h5file is not None:
583 # Check for allowed keyword arguments,
584 # to avoid unwanted arguments falling through to array constructor.
585 for kwarg in kwargs:
586 if kwarg not in self.__allowed_init_kwargs:
587 raise TypeError(
588 "%s keyword argument is not allowed" % repr(kwarg)
589 )
590
591 # Turn 'expectedsize' into 'expectedrows'.
592 if "expectedsize" in kwargs:
593 # These match since one byte is stored per row.
594 expectedrows = kwargs["expectedsize"]
595 kwargs = kwargs.copy()
596 del kwargs["expectedsize"]
597 kwargs["expectedrows"] = expectedrows
598
599 # Create a new array in the specified PyTables file.
600 self._version = NodeTypeVersions[-1]
601 shape = self._byte_shape[self._version]
602 node = h5file.create_earray(
603 atom=tb.UInt8Atom(), shape=shape, **kwargs
604 )
605
606 # Set the node attributes, else remove the array itself.
607 try:
608 self._set_attributes(node)
609 except RuntimeError:
610 h5file.remove_node(kwargs["where"], kwargs["name"])
611 raise
612
613 RawPyTablesIO.__init__(self, node, "a+")
614 self._checkReadable()
615 self._checkWritable()
616
617 @property
618 def node(self):

Callers

nothing calls this directly

Calls 6

_set_attributesMethod · 0.95
_check_attributesMethod · 0.80
create_earrayMethod · 0.80
remove_nodeMethod · 0.80
copyMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected