Natural Naming#
h5RDMtoolbox supports attribute style access (natural naming) on datasets, groups and attributes instead of the known dictionary style. This means that HDF objects must not be named as existing attributes of used instances, e.g. File.
import h5rdmtoolbox as h5tbx
h5tbx.use(None)
using("h5py")
You can enable natural naming by the following line. However, True is the default.
h5tbx.set_config(natural_naming=True)
<h5rdmtoolbox._cfg.set_config at 0x7908079763b0>
with h5tbx.File() as h5:
ds = h5.create_dataset('test', shape=(3,))
print(h5.test)
<HDF5 dataset "test": shape (3,), type "<f4", convention "h5py">
Disabeling the natural naming configuration will raise an AttributeError when running the above code:
h5tbx.set_config(natural_naming=False)
<h5rdmtoolbox._cfg.set_config at 0x790807976d10>
with h5tbx.File() as h5:
ds = h5.create_dataset('test', shape=(3,))
try:
print(h5.test)
except Exception as e:
print(e)
'File' object has no attribute 'test'