Skip to content

'to_array' creates a read-only numpy array #708

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
max-sixty opened this issue Jan 6, 2016 · 2 comments
Closed

'to_array' creates a read-only numpy array #708

max-sixty opened this issue Jan 6, 2016 · 2 comments

Comments

@max-sixty
Copy link
Collaborator

Is this intended? It's creating some problems downstream with pandas, but maybe that's a pandas issue?

Note the WRITEABLE : False here:

In [126]: ds=xray.Dataset({'a':xray.DataArray(pd.np.random.rand(5,3))}, coords={'b': xray.DataArray(pd.np.random.rand(5))})

In [127]: ds.to_array('d').b.values.flags
Out[127]: 
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : False
  ALIGNED : True
  UPDATEIFCOPY : False

Without the to_array, it's fine:

In [128]: ds.b.values.flags
Out[128]: 
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

xref pandas-dev/pandas#11502

@shoyer
Copy link
Member

shoyer commented Jan 6, 2016

Hmm. I can't reproduce this on my machine (using numpy 1.10.2 and the dev version of xray):

In [21]: ds.to_array('d').b.values.flags
Out[21]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

Which version of numpy do you have installed?

My best guess is that this might be someone related to broadcast_to, which can create read only numpy arrays. But nothing should be happening to the coordinate arrays at all with to_array...

@max-sixty
Copy link
Collaborator Author

You're right - it's on 0.6.1 only. (Apologies...)

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