Unyt is a Python package for adding unit information to numbers which uses a unyt_array class derived from NumPy's ndarray, which allows it to transparently 'drop in' to functions that use and take advantage of NumPy's array functionality.
In hickle v3.x (specifically 3.4.9, with h5py=2.10.0), saving a unyt_array with hickle and loading it would preserve the unit information attached. In v4.x of hickle (specifically 4.0.3), unit information is erased upon saving, leading to the loaded value having units of "dimensionless".
$ import unyt, hickle, h5py
$ test = [1, 2, 3] * unyt.K
$ print(test)
>>> unyt_array([1, 2, 3], 'K')
$ with h5py.File(temp, mode='w') as f:
hickle.dump(test, f, path='test')
$ with h5py.File(temp, mode='r') as f:
reconstructed = hickle.load(f, path='test')
$ print(reconstructed)
>>> unyt_array([1, 2, 3], '(dimensionless)')
Unyt is a Python package for adding unit information to numbers which uses a
unyt_array
class derived from NumPy'sndarray
, which allows it to transparently 'drop in' to functions that use and take advantage of NumPy's array functionality. Inhickle
v3.x (specifically 3.4.9, withh5py
=2.10.0), saving aunyt_array
withhickle
and loading it would preserve the unit information attached. In v4.x ofhickle
(specifically 4.0.3), unit information is erased upon saving, leading to the loaded value having units of "dimensionless".