Groups and datasets can have small bits of named information attached to them. This is the official way to store metadata in HDF5. Each of these objects has a small proxy object (AttributeManager) attached to it as <obj>.attrs. Attributes have the following properties:
They support the same dictionary API as groups.
Allows dictionary-style access to an HDF5 object’s attributes.
These are created exclusively by the library and are available as a Python attribute at <object>.attrs
Like Group objects, attributes provide a minimal dictionary- style interface. Anything which can be reasonably converted to a Numpy array or Numpy scalar can be stored.
Attributes are automatically created on assignment with the syntax <obj>.attrs[name] = value, with the HDF5 type automatically deduced from the value. Existing attributes are overwritten.
To modify an existing attribute while preserving its type, use the method modify(). To specify an attribute of a particular type and shape, use create().
Read the value of an attribute.
Set a new attribute, overwriting any existing attribute.
The type and shape of the attribute are determined from the data. To use a specific type or shape, or to preserve the type of an attribute, use the methods create() and modify().
Delete an attribute (which must already exist).
Create a new attribute, overwriting any existing attribute.
Change the value of an attribute while preserving its type.
Differs from __setitem__ in that if the attribute already exists, its type is preserved. This can be very useful for interacting with externally generated files.
If the attribute doesn’t exist, it will be automatically created.
Inherited dictionary interface
Get a list containing member names
Get a list containing member objects
Get a list of tuples containing (name, object) pairs
Get an iterator over member names
Get an iterator over member objects
Get an iterator over (name, object) pairs
Retrieve the member, or return default if it doesn’t exist