Closed gbrener closed 6 years ago
The mlds.to_features() and mlds.from_features() methods should be idempotent. Here is an example where this breaks, currently:
mlds.to_features()
mlds.from_features()
import pandas as pd import numpy as np import xarray as xr from xarray_filters import from_features, to_features, MLDataset index = pd.MultiIndex.from_product((np.arange(2), np.arange(2, 4)), names=('x', 'y')) arr1 = xr.DataArray(np.random.uniform(0,1, (4, 1)), coords=[('space', index), ('layer', ['pressure'])], dims=('space', 'layer'), name='features') dset1 = from_features(arr1) dset2 = dset1.to_features() dset2.to_features() # fails here
Traceback:
Traceback (most recent call last): File "test.py", line 12, in <module> dset2.to_features() ... ValueError: conflicting MultiIndex level name(s): 'space' (space), (space) 'layer' (space), (layer)
Fixed by #45
The
mlds.to_features()
andmlds.from_features()
methods should be idempotent. Here is an example where this breaks, currently:Traceback: