8000 Bug in Table with unicode sandwich related to order of comparison · Issue #6838 · astropy/astropy · GitHub
[go: up one dir, main page]

Skip to content
Bug in Table with unicode sandwich related to order of comparison #6838
@astrofrog

Description

@astrofrog

The following example demonstrates an issue when comparing a string column with a bytes column:

In [64]: t1 = Table(masked=True)

In [65]: t1['a'] = ['a', 'b', 'c']

In [66]: t2 = Table(masked=True)

In [67]: t2['a'] = [b'a', b'b', b'c']

In [68]: t1['a'] == t2['a']
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-68-372e9d1afaab> in <module>()
----> 1 t1['a'] == t2['a']

~/Dropbox/Code/Astropy/astropy/astropy/table/column.py in _compare(self, other)
    938             if self.dtype.char == 'S':
    939                 other = self._encode_str(other)
--> 940             return getattr(self.data, oper)(other)
    941         return _compare
    942 

~/miniconda3/envs/dev/lib/python3.6/site-packages/numpy/ma/core.py in __eq__(self, other)
   3909         else:
   3910             odata = filled(other, 0)
-> 3911             check = self.filled(0).__eq__(odata).view(type(self))
   3912             if self._mask is nomask:
   3913                 check._mask = omask

AttributeError: 'NotImplementedType' object has no attribute 'view'

In [69]: t2['a'] == t1['a']
Out[69]: 
masked_array(data = [True True True],
             mask = [False False False],
       fill_value = True)

The expected result is that t1['a'] == t2['a'] should be equal to t2['a'] == t1['a']

cc @taldcroft @mhvk

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0