-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MaskedColumn finalize not giving expected results #1471
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
Conversation
|
@taldcroft - you mentioned in ff6039e that there was a workaround for this issue, but it still doesn't seem to work. Any idea why? |
|
Ah I see this was a workaround for another piece of functionality, but wasn't addressing the real issue here. |
|
I'm going to look into this a bit now. |
…lumn metadata. This required adding a workaround for a bug in Numpy which causes MaskedArray.__getitem__ to not call __array_finalize__. Fixes astropy#1471.
|
@taldcroft - what do you think of the attached fix? Let's see if it works on Travis with all Numpy versions... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To allow sub-classes to use this too, I would suggest:
self.__array_finalize__(obj)
super(MaskedColumn, self)._update_from(obj)
Although I guess since this is for backporting, one could argue one might leave it as is, and I can just change it in #1848 if this one gets merged earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This would need to get fixed in e.g. __array_finalize__ too, and maybe elsewhere, so I'd rather leave this to another pull request.
|
@taldcroft - should I remove the workaround in ff6039e? |
|
@astrofrog - will check into this later today. |
|
That numpy.ma image is hilarious. I almost want to make it into a stiicker for my laptop. 😄 |
|
Yes, GitHub needs a "Like" button or similar. |
|
@astrofrog - This looks good to me, thanks! Taking out the workaround in ff6039e seems good, but I would add a tests that metadata gets propagated with |
|
ding ding ding ding ding we have a winner! @taldcroft has found a new bug in numpy.ma - @taldcroft - what do you think? (assuming tests pass). Too hacky? |
|
The general approach of overriding |
|
Take does work with scalar values - but in the above case you'll only get something valid with 0 or 1 since the column has a length of 2. I'll add the tests anyway just to make sure it's all working fine. |
|
@taldcroft - I've added tests for scalar values in |
|
@taldcroft - |
|
@taldcroft - should we merge this irrespective of the ongoing discussion about subclassing |
|
This looks good to merge. |
MaskedColumn finalize not giving expected results
MaskedColumn finalize not giving expected results Conflicts: astropy/table/column.py
MaskedColumn finalize not giving expected results Conflicts: astropy/table/column.py

Slicing or doing other operations on a masked column doesn't propagate the other attributes: