pninexus.h5cpp.node
¶
Enumerations¶
Classes¶
- class pninexus.h5cpp.node.Node¶
Base class for all node types.
hello world this is some stupid text
- attributes¶
Read-only property providing access to the
pninexus.h5cpp.attribute.AttributeManager
instance associated with the node
- is_valid¶
Read-only property returning true if the node is a valid HDF5 object. False otherweise.
- Returns:
True
if node is valid object,False
otherwise- Return type:
Boolean
- class pninexus.h5cpp.node.Group¶
HDF5 group class.
- Parameters:
parent (Group) – the parent group below which to construct the new group
name (str) – the name for the new group
lcpl (pninexus.h5cpp.property.LinkCreationList) – optional link creation property list
gcpl (pninexus.h5cpp.property.GroupCreationList) – optional group creation property list
gapl (pninexus.h5cpp.property.GroupAccessList) – optional group access property list
- links¶
Read only property returning the link view instance associated with this group instance.
- Return type:
- nodes¶
Read only property returning the node view instance associated with this group.
- Return type:
- close()¶
Closes the group. After a call to this method the
is_valid
property returnsFalse
.group = Group(...) group.is_valid #returns True group.close() group.is_valid #returns False
- class pninexus.h5cpp.node.Dataset¶
Datasets are the primary data storing nodes in HDF5.
The constructor for a dataset takes the following arguments:
- Parameters:
parent (Group) – the parent group for the new dataset
name (str) – the name for the new dataset
type (pninexus.h5cpp.datatype.Datatype) – the datatype for the new dataset
space (pninexus.h5cpp.dataspace.Dataspace) – the dataspace for the dataset
lcpl (pninexus.h5cpp.property.LinkCreationList) – an optional link creation property list
dcpl (pninexus.h5cpp.property.DatasetCreationList) – an optional dataset creation property list
dapl (pninexus.h5cpp.property.DatasetAccessList) – an optional dataset access property list
- access_list¶
Read-only attribute returning the access property list used when opening the dataset.
- Return type:
- creation_list¶
Read-only attribute returning the creation property list used during dataset creation.
- Return type:
- dataspace¶
Read only attribute returning the associated with this dataset
- Return type:
- datatype¶
Read only attribute returning the datatype associated with the dataset.
- Return type:
- close()¶
Closes the dataset. After calling this function
is_valid
should returnFalse
.
- refresh()¶
When built with HDF5 > 1.10 this method can be used in SWMR mode to obtain updates to the dataset from the writer.
- extent(new_shape)¶
Set the extent (number of elements along each dimension) for a dataset. new_shape is a tuple or list with the new number of elements. In order for this method to succeed
the number of dimensions (or rank) must remain the same
the dataset must be constructed with a chunked storage layout
- Parameters:
new_shape (tuple) – new number of elements
- Raises:
RuntimeError – in case of a failure
- extent(dim_index, dim_delta)
Change the number of elements of a dataset along a particular dimensions by a delta.
from pninexus.h5cpp.dataspace import Simple,UNLIMITED from pninexus.h5cpp.node import Dataset current_space = Simple((10,10),(UNLIMITED,10)) dataset = Dataset(...,current_space) #do something with the dataset here dataset.extent(0,10) current_space = dataset.dataspace print(current_space.current_dimensions) #output (15,10)
- Parameters:
dim_index (int) – index of the dimension for which to reset the extent
dim_delta (int) – change in number of dimensions
- Raises:
RuntimeError – in case of a failure
- write(data, selection=None)
write data to a dataset
Writes data to a dataset
- Parameters:
data (object) – Python object with data to write
selection (pninexus.h5cpp.dataspace.Selection) – an optional selection
- Raises:
RuntimeError – in case of a failure
Write data to the dataset. The data argument is a reference to the Python object storing the data to write. Internally this object will be converted to a numpy array which is then written to disk. If data is already an instance of
numpy.ndarray
this conversion is omitted.In addition to the data an optinal reference to an HDF5 selection
pninexus.h5cpp.dataspace.Selection
can be passed to the method determining where in the dataset the data will be written. If no selection is passed the data will be assumed to fit into the entire dataset.- Parameters:
write (object) – reference to the object to write
selection (pninexus.h5cpp.dataspace.Selection) – optional selection for the dataset
- Raises:
RuntimeError – in case of a failure
- read(data=None, selection=None)
read data from a dataset
Reads data from a dataset
- Parameters:
data (object) – Python object with data to read
selection (pninexus.h5cpp.dataspace.Selection) – an optional selection
- Returns:
read data
- Raises:
RuntimeError – in case of a failure
Reading data from a dataset. If called with no argument this method reads all data from the dataset and returns it as an instance of
numpy.ndarray
. With the selection parameter an HDF5 selection can be passed to determine what data from the dataset to read.The optional data argument must be a reference to an instance of a numpy array (
numpy.ndarray
). If data is notNone
the method tries to read the data inplace to this numpy array thus avoiding memory additional memory allocation. In order for this to succeed the numpy array has to satisfy the following criteriathe datatype of the datatype must be convertible to the type of the numpy array
the number of elements of the numpy array must match those of the dataset or the selection if provided.
- Parameters:
data (numpy.ndarray) – optional data reference for inplace reading
pninexus.h5cpp.dataspace.Selection – selection determining what to read
- Raises:
RuntimeError – in case of a failure
TypeError – if data is not an instance of
numpy.ndarray
- filters()¶
read filters from a dataset
Reads filters from a dataset
- Returns:
a list of filters
- Raises:
RuntimeError – in case of a failure
- read(data=None, selection=None)¶
read data from a dataset
Reads data from a dataset
- Parameters:
data (object) – Python object with data to read
selection (pninexus.h5cpp.dataspace.Selection) – an optional selection
- Returns:
read data
- Raises:
RuntimeError – in case of a failure
- write(data, selection=None)¶
write data to a dataset
Writes data to a dataset
- Parameters:
data (object) – Python object with data to write
selection (pninexus.h5cpp.dataspace.Selection) – an optional selection
- Raises:
RuntimeError – in case of a failure
- class pninexus.h5cpp.node.LinkView¶
Iterable interface to the links directly attached to a group. The link view for a group can be accessed via the
links
attribute of aGroup
instance.Iteration over the links immediately attached to a group:
group = ... for link in group.links: print(link.path)
Recursive iteration over all links available below a group and its sub-groups
group = ... for link in group.links.recursive: print(link.path)
- recursive¶
Read-only property returning a recursive link iterator
- exists(link_name, lapl=pninexus.h5cpp.property.LinkAccessList())¶
Returns
True
if a link of name link_name exists below the associated group, otherwiseFalse
is returned.- Parameters:
link_name (str) – name of the link to check for
lapl (pninexus.h5cpp.property.LinkAccessList) – optional link access property list
- Returns:
True
if link exists,False
otherwise- Return type:
boolean
- class pninexus.h5cpp.node.NodeView¶
Iterable interface to the nodes below an instance of
Group
. The instance ofNodeView
associated with a particular group can be accessed via thenodes
property of the latter.group = ... for node in group.nodes: print(node.link.path)
like for links there is also a recursive iterator available which returns also the children of all sub-groups of a group.
group = ... for node in group.nodes.recursive: print(node.link.path)
- recursive¶
Read only property returning a recursive node iterator.
- exists(node_name, lapl=pninexus.h5cpp.property.LinkAccessList())¶
Returns true if a node of name node_name exists below a group. Otherwise
False
is returned. This check involves two steps under the hoodcheck if a link of name node_name exists
check if the link can be resolved
only if both checks succeed
True
is returned.- Parameters:
node_name (str) – the name of the node to check for
lapl (pninexus.h5cpp.property.LinkAccessList) – optional link access property list
- Returns:
True
if the node exists,False
otherwise- Return type:
boolean
- class pninexus.h5cpp.node.Link¶
Class representing a link. You cannot construct an instance of
Link
from within Python, but you can obtain them from several methods and properties of the node classes.- exists¶
Read-only property returning
True
if the link exists,False
otherwise.- Return type:
boolean
- file¶
Read-only attribute returning the path to the file within which the link exists.
- Return type:
str
- is_resolvable¶
Read-only attribute returning
True
if the link can be resolved,False
otherwise.- Return type:
boolean
- node¶
Read-only property returning the node referenced by this link. This will only work if the link itself is resolvable.
link = .... if link.is_resolvable: node = link.node
- path¶
Return the path for the link.
- Return type:
- type(lapl=pninexus.h5cpp.property.LinkAccessList())¶
Return the type.
- Parameters:
lapl (pninexus.h5cpp.property.LinkAccessList) – optional link access proerty list
- Returns:
link type enumeration
- Return type:
- target(lapl=pninexus.h5cpp.property.LinkAccessList())¶
Return the link target
- Parameters:
lapl (pninexus.h5cpp.property.LinkAccessList) – optional link access property list
- Returns:
the target of the link
- Return type:
- class pninexus.h5cpp.node.LinkTarget¶
LinkTarget
describes the target for a link. It could be used to access this target without dereferencing the link. It is thus useful in the case of links which cannot be dereferenced. Using the target one could check whether the file or the object in it are missing or both.- file_path¶
Read only property with the path to the file where the link target is expected to reside in. In the case of soft links this is empty.
- Return type:
str
- object_path¶
Read only property returning the node path to the target.
- Return type: