Attributes are a critical part of what makes HDF5 a “self-describing” format. They are small named pieces of data attached directly to Group and Dataset objects. This is the official way to store metadata in HDF5.
Each Group or Dataset has a small proxy object attached to it, at <obj>.attrs. Attributes have the following properties:
The .attrs proxy objects are of class AttributeManager, below. This class supports a dictionary-style interface.
AttributeManager objects are created directly by h5py. You should access instances by group.attrs or dataset.attrs, not by manually creating them.
Get an iterator over attribute names.
Determine if attribute name is attached to this object.
Retrieve an attribute.
Create an attribute, overwriting any existing attribute. The type and shape of the attribute are determined automatically by h5py.
Delete an attribute. KeyError if it doesn’t exist.
Get the names of all attributes attached to this object. On Py2, this is a list. On Py3, it’s a set-like object.
Get the values of all attributes attached to this object. On Py2, this is a list. On Py3, it’s a collection or bag-like object.
Get (name, value) tuples for all attributes attached to this object. On Py2, this is a list of tuples. On Py3, it’s a collection or set-like object.
(Py2 only) Get an iterator over attribute names.
(Py2 only) Get an iterator over attribute values.
(Py2 only) Get an iterator over (name, value) pairs.
Retrieve name, or default if no such attribute exists.
Create a new attribute, with control over the shape and type. Any existing attribute will be overwritten.
Parameters: |
|
---|
Change the value of an attribute while preserving its type and shape. Unlike AttributeManager.__setitem__(), if the attribute already exists, only its value will be changed. This can be useful for interacting with externally generated files, where the type and shape must not be altered.
If the attribute doesn’t exist, it will be created with a default shape and type.
Parameters: |
|
---|