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

Better error message when assigning coordinates without dimensions #971

Merged
merged 3 commits into from
Aug 18, 2016

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Aug 17, 2016

Fixes #969

@shoyer shoyer force-pushed the better-setitem-errors branch 2 times, most recently from f685c36 to 25bebc8 Compare August 17, 2016 03:22
@@ -42,7 +42,7 @@ def as_variable(obj, name=None, copy=False):
obj = obj.copy(deep=False)
elif hasattr(obj, 'dims') and (hasattr(obj, 'data') or
hasattr(obj, 'values')):
obj = Variable(obj.dims, getattr(obj, 'data', obj.values),
obj = Variable(obj.dims, getattr(obj, 'data', getattr(obj, 'values')),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, why is this better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was confused when I switched this. It does literally the exact
same thing - I will revert. My concern was that this might prematurely
evaluate the data if it's a dask array.
On Tue, Aug 16, 2016 at 9:16 PM Maximilian Roos notifications@github.com
wrote:

In xarray/core/variable.py
#971 (comment):

@@ -42,7 +42,7 @@ def as_variable(obj, name=None, copy=False):
obj = obj.copy(deep=False)
elif hasattr(obj, 'dims') and (hasattr(obj, 'data') or
hasattr(obj, 'values')):

  •    obj = Variable(obj.dims, getattr(obj, 'data', obj.values),
    
  •    obj = Variable(obj.dims, getattr(obj, 'data', getattr(obj, 'values')),
    

Out of interest, why is this better?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/pydata/xarray/pull/971/files/25bebc8c427f5947545ba3de101ca02108754037#r75060357,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABKS1s27hTk1CurNGfup--qbCecMSdZaks5qgosBgaJpZM4JmDcq
.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think getattr is only useful if you don't know what attr it might be. But no harm!

@shoyer shoyer merged commit 4295b93 into pydata:master Aug 18, 2016
@shoyer shoyer deleted the better-setitem-errors branch August 18, 2016 01:03
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

Successfully merging this pull request may close these issues.

2 participants