Module H5A¶
Provides access to the low-level HDF5 “H5A” attribute interface.
- class h5py.h5a.AttrID¶
Logical representation of an HDF5 attribute identifier.
Objects of this class can be used in any HDF5 function call which expects an attribute identifier. Additionally, all H5A* functions which always take an attribute instance as the first argument are presented as methods of this class.
- Hashable: No
- Equality: Identifier comparison
- dtype¶
- A Numpy-stype dtype object representing the attribute’s datatype
- get_name() → STRING name¶
- Determine the name of this attribute.
- get_space() → SpaceID¶
- Create and return a copy of the attribute’s dataspace.
- get_storage_size() → INT¶
- Get the amount of storage required for this attribute.
- get_type() → TypeID¶
- Create and return a copy of the attribute’s datatype.
- name¶
- The attribute’s name
- read(NDARRAY arr)¶
Read the attribute data into the given Numpy array. Note that the Numpy array must have the same shape as the HDF5 attribute, and a conversion-compatible datatype.
The Numpy array must be writable and C-contiguous. If this is not the case, the read will fail with an exception.
- shape¶
- A Numpy-style shape tuple representing the attribute’s dataspace
- write(NDARRAY arr)¶
Write the contents of a Numpy array too the attribute. Note that the Numpy array must have the same shape as the HDF5 attribute, and a conversion-compatible datatype.
The Numpy array must be C-contiguous. If this is not the case, the write will fail with an exception.
- h5py.h5a.create(ObjectID loc, STRING name, TypeID tid, SpaceID space, **kwds) → AttrID¶
Create a new attribute, attached to an existing object.
- STRING obj_name (“.”)
- Attach attribute to this group member instead
- PropID lapl
- Link access property list for obj_name
- h5py.h5a.delete(ObjectID loc, STRING name=, INT index=, **kwds)¶
Remove an attribute from an object. Specify exactly one of “name” or “index”. Keyword-only arguments:
- STRING obj_name (“.”)
- Attribute is attached to this group member
- PropID lapl (None)
- Link access property list for obj_name
INT index_type (h5.INDEX_NAME)
INT order (h5.ITER_NATIVE)
- h5py.h5a.exists(ObjectID loc, STRING name, **kwds) → BOOL¶
Determine if an attribute is attached to this object. Keywords:
- STRING obj_name (“.”)
- Look for attributes attached to this group member
- PropID lapl (None):
- Link access property list for obj_name
- h5py.h5a.get_info(ObjectID loc, STRING name=, INT index=, **kwds) → AttrInfo¶
Get information about an attribute, in one of two ways:
- If you have the attribute identifier, just pass it in
- If you have the parent object, supply it and exactly one of either name or index.
- STRING obj_name (“.”)
- Use this group member instead
- PropID lapl (None)
- Link access property list for obj_name
- INT index_type (h5.INDEX_NAME)
- Which index to use
- INT order (h5.ITER_NATIVE)
- What order the index is in
- h5py.h5a.get_num_attrs(ObjectID loc) → INT¶
- Determine the number of attributes attached to an HDF5 object.
- h5py.h5a.iterate(ObjectID loc, CALLABLE func, INT index=0, **kwds) → <Return value from func>¶
Iterate a callable (function, method or callable object) over the attributes attached to this object. You callable should have the signature:
func(STRING name) => Result
or if the keyword argument “info” is True:
func(STRING name, AttrInfo info) => Result
Returning None continues iteration; returning anything else aborts iteration and returns that value. Keywords:
- BOOL info (False)
- Callback is func(STRING name, AttrInfo info), not func(STRING name)
- INT index_type (h5.INDEX_NAME)
- Which index to use
- INT order (h5.ITER_NATIVE)
- Index order to use
- h5py.h5a.open(ObjectID loc, STRING name=, INT index=, **kwds) → AttrID¶
Open an attribute attached to an existing object. You must specify exactly one of either name or idx. Keywords are:
- STRING obj_name (“.”)
- Attribute is attached to this group member
- PropID lapl (None)
- Link access property list for obj_name
INT index_type (h5.INDEX_NAME)
INT order (h5.ITER_NATIVE)
- h5py.h5a.rename(ObjectID loc, STRING name, STRING new_name, **kwds)¶
Rename an attribute. Keywords:
- STRING obj_name (“.”)
- Attribute is attached to this group member
- PropID lapl (None)
- Link access property list for obj_name