Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLDataset.*_features() should be idempotent #38

Closed
gbrener opened this issue Oct 27, 2017 · 1 comment
Closed

MLDataset.*_features() should be idempotent #38

gbrener opened this issue Oct 27, 2017 · 1 comment
Assignees

Comments

@gbrener
Copy link
Contributor

gbrener commented Oct 27, 2017

The mlds.to_features() and mlds.from_features() methods should be idempotent. Here is an example where this breaks, currently:

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)
@PeterDSteinberg
Copy link
Contributor

Fixed by #45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants