pninexus.h5cpp.attribute¶
AttributeManager¶
-
class
pninexus.h5cpp.attribute.AttributeManager¶ Every instance of
Nodehas an instance ofAttributeManagerattached to it which provides access to the attributes attached to the particular node.-
size¶ Read-only property returning the number of attributs of a node.
- Returns
number of attributes
- Return type
integer
-
create()¶ Creates a new attribute on the node to which the manager instance is attached.
- Parameters
name (str) – the name of the new attribute
type (pni.io.h5cpp.datatype.Datatype) – a datatype instance
space (pni.io.h5cpp.dataspace.Dataspace) – the dataspace for the attribute
pni.io.h5cpp.property.AttributeCreationList – an optional attribute creation property list
- Returns
a new instance of
Attribute- Return type
pni.io.h5cpp.attribute.Attribute- Raises
RuntimeError – in case of an error
-
remove()¶ Removes an attribute from a node. Raises
RuntimeErrorif the node does not exist.- Parameters
index (object) – the index of the node to remove. This can either be a numerical index or the name of the attribute.
- Raises
RuntimeError – in case of a failure
-
__len__()¶ The attribute manager supports the __len__ protocol so one can use the
len()function to determine the number of attributes attached to a node.root = file.root() print("Number of attributes: {}".format(len(root.attributes)))
-
exists()¶ Takes the name of an attribute as its sole argument and returns
Trueif an attribute of that name exists, otherwise it returnsFalse.- Parameters
name (str) – the name of an attribute
- Returns
Trueif the attribute exists,Falseotherwise- Return type
bool
-
__getitem__()¶ Reads data from an attribute and allows slicing.
data = dataset.attributes["tensor"][1,2,2]
A numpy array is returned.
- Parameters
index (slice) – the selection for the data to read
- Returns
numpy array with the data
- Return type
numpy.ndarray
-
Attribute¶
-
class
pninexus.h5cpp.attribute.Attribute¶ a = dataset.attribtues.create() a.write("m")
Attributes can be obtained with
a = dataset.attributes["temperature"] print(a.read())
-
dataspace¶ read-only property returning the dataspace for the attribute
-
datatype¶ read-only property returning the HDF5 datatype of the attribute
-
name¶ read-only property returning the name of the attribute as an instance of
str
-
is_valid¶ read-only property returning
Trueif the attribute is a valid HDF5 object, andFalseotherwise
-
parent_link¶ read-only property returning a link to the parent node of the attribute as an instance of
pni.io.h5cpp.node.Link.
-
close()¶ closes the current attribute
-
read()¶ Reads attribute data and returns it as an instance of
numpy.ndarray.
-
write(data)¶ Takes an instance of a Python object and writes it to the attribute.
-