-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
filtering masked tables resets column fill_value #4707
Copy link
Copy link
Closed
Labels
BugClose?Tell stale bot that this issue/PR is staleTell stale bot that this issue/PR is staleio.fitstable
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugClose?Tell stale bot that this issue/PR is staleTell stale bot that this issue/PR is staleio.fitstable