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

filtering masked tables resets column fill_value #4707

Closed
sbailey opened this issue Mar 18, 2016 · 7 comments
Closed

filtering masked tables resets column fill_value #4707

sbailey opened this issue Mar 18, 2016 · 7 comments

Comments

@sbailey
Copy link
Contributor

sbailey commented Mar 18, 2016

filtering a masked table resets the fill value to 1:

In [1]: from astropy.table import Table

In [2]: a = Table(masked=True)

In [3]: a['X'] = [0,1,2,3]

In [4]: a['Y'] = [0,1,2,3]

In [5]: a['Y'].mask = [False, False, False, True]

In [6]: print a['Y'].fill_value
999999

In [7]: a
Out[7]: 
<Table masked=True length=4>
  X     Y  
int64 int64
----- -----
    0     0
    1     1
    2     2
    3    --

In [8]: a = a[a['Y']<3]

In [9]: print a['Y'].fill_value
1

This is dangerous because it reset the fill value to a valid value in the table, which breaks how masked values are tracked in FITS-format tables (I'll submit a separate issue about that). But filtering shouldn't reset the fill value in the first place.

In [10]: a
Out[10]: 
<Table masked=True length=3>
  X     Y  
int64 int64
----- -----
    0     0
    1     1
    2     2

In [11]: a.write('blat.fits', overwrite=True)

In [12]: b = Table.read('blat.fits')

In [13]: b
Out[13]: 
<Table masked=True length=3>
  X     Y  
int64 int64
----- -----
    0     0
    1    --
    2     2

The end result is that after filtering my masked table, round-tripping it to a FITS file gives me back a different table, with one of my previously unmasked values now masked.

@pllim
Copy link
Member

pllim commented Mar 21, 2016

Maybe less confusing to just address this in #4708 since they are related?

@pllim pllim closed this as completed Mar 21, 2016
@sbailey
Copy link
Contributor Author

sbailey commented Mar 21, 2016

Fine to treat this as a single ticket if both #4707 and #4708 are fixed simultaneously. But they are separate issues — resetting the fill value when filtering could be problematic even if no I/O is ever performed with the table. It may be possible to usefully fix this ticket by itself even if the FITS I/O issue #4708 requires more work.

@pllim
Copy link
Member

pllim commented Mar 21, 2016

Ok. Re-opening. Thanks for the clarifications.

@pllim pllim reopened this Mar 21, 2016
@pllim pllim added Bug and removed Duplicate labels Mar 21, 2016
@saimn
Copy link
Contributor

saimn commented Oct 3, 2017

Seems to be fixed, maybe it was a Numpy issue with subclasses ?

@saimn saimn added the Close? label Oct 3, 2017
@astropy-bot
Copy link

astropy-bot bot commented Mar 8, 2018

Hi humans 👋 - this issue was labeled as Close? approximately 5 months ago. So..... any news? 🗞️

If you think this issue should not be closed, a maintainer should remove the Close? label - otherwise, I'm just gonna have to close this issue in a month. Your time starts now! Tick tock 🕙

If you believe I commented on this issue incorrectly, please report this here

@saimn
Copy link
Contributor

saimn commented Mar 8, 2018

Ok, closing as I still cannot reproduce.

@saimn saimn closed this as completed Mar 8, 2018
@sbailey
Copy link
Contributor Author

sbailey commented Mar 8, 2018

I confirm that this problem still exists with astropy/2.0.2 + numpy 1.11.1 but it is fixed with astropy/2.0.2 + numpy/1.13.1 . OK with me to leave it closed.

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

No branches or pull requests

3 participants