[AstroPy] Query about Table.add_row() method for masked tables
Erik Bray
embray at stsci.edu
Fri Oct 2 11:48:39 EDT 2015
On 10/1/2015 4:30 PM, Josh Tan wrote:
> Hello,
>
> I have been trying to use astropy tables and have found that you cannot add a
> `None` row with a mask. While I can go and add np.zeroes by hand, it’s a bit
> annoying to me that it behaves this way. (See examples below.)
Hi Josh,
There definitely seems to be some conflict between add_row(None) and
add_row(..., mask=...). It seems to be that the allowed formats for the mask
value aren't really compatible with the add_row(None) syntax. I think that
could be fixed--the way you were trying to do it, add_row(None, mask=True),
makes sense to me.
Erik
> In [69]:
>
> t =Table([[1], [2]],names=('a','b'),masked=True)
>
> t.add_row(None,mask=True)
>
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-69-4b6f404ff930> in<module>() 1 t= Table([[1], [2]], names=('a', 'b'), masked=True)
> ----> 2t.add_row(None, mask=True)
>
> /Users/joshuaschroeder/Documents/Ureka/python/lib/python2.7/site-packages/astropy/table/table.pyc inadd_row(self, vals, mask) 1623 3 6 9
> 1624 """
> -> 1625self.insert_row(len(self), vals, mask)
> 1626
> 1627 def insert_row(self, index, vals=None, mask=None):
>
> /Users/joshuaschroeder/Documents/Ureka/python/lib/python2.7/site-packages/astropy/table/table.pyc ininsert_row(self, index, vals, mask) 1674 # that have entries for each table column.
> 1675 if maskis not Noneand not _is_mapping(mask):
> -> 1676raise TypeError("Mismatch between type of vals and mask")
> 1677
> 1678 # Now check that the mask is specified for the same keys as the
>
> TypeError: Mismatch between type of vals and mask
>
>
> In [74]:
>
> t =Table([[1], [2]],names=('a','b'),masked=True)
>
> t.add_row(None,mask=len(t.colnames)*[True])
>
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-74-ae9160dbf05d> in<module>() 1 t= Table([[1], [2]], names=('a', 'b'), masked=True)
> ----> 2t.add_row(None, mask=len(t.colnames)*[True])
>
> /Users/joshuaschroeder/Documents/Ureka/python/lib/python2.7/site-packages/astropy/table/table.pyc inadd_row(self, vals, mask) 1623 3 6 9
> 1624 """
> -> 1625self.insert_row(len(self), vals, mask)
> 1626
> 1627 def insert_row(self, index, vals=None, mask=None):
>
> /Users/joshuaschroeder/Documents/Ureka/python/lib/python2.7/site-packages/astropy/table/table.pyc ininsert_row(self, index, vals, mask) 1674 # that have entries for each table column.
> 1675 if maskis not Noneand not _is_mapping(mask):
> -> 1676raise TypeError("Mismatch between type of vals and mask")
> 1677
> 1678 # Now check that the mask is specified for the same keys as the
>
> TypeError: Mismatch between type of vals and mask
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
>
More information about the AstroPy
mailing list