Skip to content

Unable to load pickle Dataset that was picked with cPickle #167

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

Closed
rzlee opened this issue Jun 21, 2014 · 1 comment · Fixed by #168
Closed

Unable to load pickle Dataset that was picked with cPickle #167

rzlee opened this issue Jun 21, 2014 · 1 comment · Fixed by #168
Assignees
Labels
Milestone

Comments

@rzlee
Copy link

rzlee commented Jun 21, 2014

import cPickle as pickle
import xray
import numpy as np
import pandas as pd

foo_values = np.random.RandomState(0).rand(3,4)
times = pd.date_range('2001-02-03', periods=3)
ds = xray.Dataset({'time': ('time', times), 'foo': (['time', 'space'], foo_values)})

with open('mypickle.pkl', 'w') as f:
    pickle.dump(ds, f)

with open('mypickle.pkl') as f:
    myds = pickle.load(f)

myds

This code results in:
<repr(<xray.dataset.Dataset at 0x7f95a3290d90>) failed: AttributeError: mapping>

@shoyer shoyer added this to the 0.2 milestone Jun 21, 2014
@shoyer shoyer added the bug label Jun 21, 2014
@shoyer shoyer self-assigned this Jun 21, 2014
@akleeman
Copy link
Contributor

At least temporarily you might consider this:

myds = xray.open_dataset(ds.dumps())

shoyer added a commit to shoyer/xarray that referenced this issue Jun 22, 2014
Fixes pydata#167

Related: pydata#166 (though I'm not sure why that didn't work)
keewis pushed a commit to keewis/xarray that referenced this issue Jan 17, 2024
Fix link to anytree issue.

Co-authored-by: Tom Nicholas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants