Activate a Convention#
This section will take you through the steps of activating a convention and find out about registered ones.
from h5rdmtoolbox import convention
import h5rdmtoolbox as h5tbx
Conventions are registered. If we design a new one, it will only be usable if it is registered.
To list all available convention, call get_registered_conventions().
convention.get_registered_conventions()
{'h5py': Convention("h5py")}
Standard conventions#
Two conventions are shipped with the toolbox: “h5py” and “h5tbx”. Without activating any convention, “h5py” will be in place. In fact, it does nothing and mimics the behavior of the h5py package. This means, that methods like create_dataset do not expect other parameters, as we know from the h5py-package.
Which convention is currently activated?
cv = convention.get_current_convention()
cv
Convention("h5py")
Activating a convention#
To activate a convention, call use() and pass its name:
h5tbx.use('h5tbx')
using("h5tbx")
To deactivate a convention, pass None or “h5py”
h5tbx.use(None)
using("h5py")
We can also use a context manager to activate a convention only for part of the code:
print(convention.get_current_convention().name)
with h5tbx.use('h5tbx'):
print(convention.get_current_convention().name)
print(convention.get_current_convention().name)
h5py
h5tbx
h5py
To find out how to work with a convention, please go to the next section.