astropy: BUG: Table test failures with np 1.23.0rc3

====================================================================== FAILURES =======================================================================
__________________________________________________________ test_col_unicode_sandwich_unicode __________________________________________________________
numpy.core._exceptions._UFuncNoLoopError: ufunc 'not_equal' did not contain a loop with signature matching types (<class 'numpy.dtype[str_]'>, <class 'numpy.dtype[bytes_]'>) -> None

The above exception was the direct cause of the following exception:

    def test_col_unicode_sandwich_unicode():
        """
        Sanity check that Unicode Column behaves normally.
        """
        uba = 'bä'
        uba8 = uba.encode('utf-8')
    
        c = table.Column([uba, 'def'], dtype='U')
        assert c[0] == uba
        assert isinstance(c[:0], table.Column)
        assert isinstance(c[0], str)
        assert np.all(c[:2] == np.array([uba, 'def']))
    
        assert isinstance(c[:], table.Column)
        assert c[:].dtype.char == 'U'
    
        ok = c == [uba, 'def']
        assert type(ok) == np.ndarray
        assert ok.dtype.char == '?'
        assert np.all(ok)
    
>       assert np.all(c != [uba8, b'def'])

astropy/table/tests/test_column.py:777: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Column dtype='str3' length=2>
 bä
def, other = [b'b\xc3\xa4', b'def']

    def _compare(self, other):
        op = oper  # copy enclosed ref to allow swap below
    
        # Special case to work around #6838.  Other combinations work OK,
        # see tests.test_column.test_unicode_sandwich_compare().  In this
        # case just swap self and other.
        #
        # This is related to an issue in numpy that was addressed in np 1.13.
        # However that fix does not make this problem go away, but maybe
        # future numpy versions will do so.  NUMPY_LT_1_13 to get the
        # attention of future maintainers to check (by deleting or versioning
        # the if block below).  See #6899 discussion.
        # 2019-06-21: still needed with numpy 1.16.
        if (isinstance(self, MaskedColumn) and self.dtype.kind == 'U'
                and isinstance(other, MaskedColumn) and other.dtype.kind == 'S'):
            self, other = other, self
            op = swapped_oper
    
        if self.dtype.char == 'S':
            other = self._encode_str(other)
    
        # Now just let the regular ndarray.__eq__, etc., take over.
>       result = getattr(super(Column, self), op)(other)
E       FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison

astropy/table/column.py:329: FutureWarning
______________________________________________ test_unicode_sandwich_compare[MaskedColumn-MaskedColumn] _______________________________________________

class1 = <class 'astropy.table.column.MaskedColumn'>, class2 = <class 'astropy.table.column.MaskedColumn'>

    @pytest.mark.parametrize('class1', [table.MaskedColumn, table.Column])
    @pytest.mark.parametrize('class2', [table.MaskedColumn, table.Column, str, list])
    def test_unicode_sandwich_compare(class1, class2):
        """Test that comparing a bytestring Column/MaskedColumn with various
        str (unicode) object types gives the expected result.  Tests #6838.
        """
        obj1 = class1([b'a', b'c'])
        if class2 is str:
            obj2 = 'a'
        elif class2 is list:
            obj2 = ['a', 'b']
        else:
            obj2 = class2(['a', 'b'])
    
        assert np.all((obj1 == obj2) == [True, False])
        assert np.all((obj2 == obj1) == [True, False])
    
        assert np.all((obj1 != obj2) == [False, True])
        assert np.all((obj2 != obj1) == [False, True])
    
>       assert np.all((obj1 > obj2) == [False, True])
E       TypeError: '>' not supported between instances of 'MaskedColumn' and 'MaskedColumn'

astropy/table/tests/test_column.py:857: TypeError
_________________________________________________ test_unicode_sandwich_compare[Column-MaskedColumn] __________________________________________________

class1 = <class 'astropy.table.column.MaskedColumn'>, class2 = <class 'astropy.table.column.Column'>

    @pytest.mark.parametrize('class1', [table.MaskedColumn, table.Column])
    @pytest.mark.parametrize('class2', [table.MaskedColumn, table.Column, str, list])
    def test_unicode_sandwich_compare(class1, class2):
        """Test that comparing a bytestring Column/MaskedColumn with various
        str (unicode) object types gives the expected result.  Tests #6838.
        """
        obj1 = class1([b'a', b'c'])
        if class2 is str:
            obj2 = 'a'
        elif class2 is list:
            obj2 = ['a', 'b']
        else:
            obj2 = class2(['a', 'b'])
    
        assert np.all((obj1 == obj2) == [True, False])
        assert np.all((obj2 == obj1) == [True, False])
    
        assert np.all((obj1 != obj2) == [False, True])
        assert np.all((obj2 != obj1) == [False, True])
    
>       assert np.all((obj1 > obj2) == [False, True])
E       TypeError: '>' not supported between instances of 'MaskedColumn' and 'Column'

astropy/table/tests/test_column.py:857: TypeError
____________________________________________________ test_unicode_sandwich_compare[Column-Column] _____________________________________________________
numpy.core._exceptions._UFuncNoLoopError: ufunc 'equal' did not contain a loop with signature matching types (<class 'numpy.dtype[str_]'>, <class 'numpy.dtype[bytes_]'>) -> None

The above exception was the direct cause of the following exception:

class1 = <class 'astropy.table.column.Column'>, class2 = <class 'astropy.table.column.Column'>

    @pytest.mark.parametrize('class1', [table.MaskedColumn, table.Column])
    @pytest.mark.parametrize('class2', [table.MaskedColumn, table.Column, str, list])
    def test_unicode_sandwich_compare(class1, class2):
        """Test that comparing a bytestring Column/MaskedColumn with various
        str (unicode) object types gives the expected result.  Tests #6838.
        """
        obj1 = class1([b'a', b'c'])
        if class2 is str:
            obj2 = 'a'
        elif class2 is list:
            obj2 = ['a', 'b']
        else:
            obj2 = class2(['a', 'b'])
    
        assert np.all((obj1 == obj2) == [True, False])
>       assert np.all((obj2 == obj1) == [True, False])

astropy/table/tests/test_column.py:852: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Column dtype='str1' length=2>
a
b, other = <Column dtype='bytes1' length=2>
a
c

    def _compare(self, other):
        op = oper  # copy enclosed ref to allow swap below
    
        # Special case to work around #6838.  Other combinations work OK,
        # see tests.test_column.test_unicode_sandwich_compare().  In this
        # case just swap self and other.
        #
        # This is related to an issue in numpy that was addressed in np 1.13.
        # However that fix does not make this problem go away, but maybe
        # future numpy versions will do so.  NUMPY_LT_1_13 to get the
        # attention of future maintainers to check (by deleting or versioning
        # the if block below).  See #6899 discussion.
        # 2019-06-21: still needed with numpy 1.16.
        if (isinstance(self, MaskedColumn) and self.dtype.kind == 'U'
                and isinstance(other, MaskedColumn) and other.dtype.kind == 'S'):
            self, other = other, self
            op = swapped_oper
    
        if self.dtype.char == 'S':
            other = self._encode_str(other)
    
        # Now just let the regular ndarray.__eq__, etc., take over.
>       result = getattr(super(Column, self), op)(other)
E       FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison

astropy/table/column.py:329: FutureWarning
___________________________________________________ test_unicode_sandwich_compare[str-MaskedColumn] ___________________________________________________

class1 = <class 'astropy.table.column.MaskedColumn'>, class2 = <class 'str'>

    @pytest.mark.parametrize('class1', [table.MaskedColumn, table.Column])
    @pytest.mark.parametrize('class2', [table.MaskedColumn, table.Column, str, list])
    def test_unicode_sandwich_compare(class1, class2):
        """Test that comparing a bytestring Column/MaskedColumn with various
        str (unicode) object types gives the expected result.  Tests #6838.
        """
        obj1 = class1([b'a', b'c'])
        if class2 is str:
            obj2 = 'a'
        elif class2 is list:
            obj2 = ['a', 'b']
        else:
            obj2 = class2(['a', 'b'])
    
        assert np.all((obj1 == obj2) == [True, False])
        assert np.all((obj2 == obj1) == [True, False])
    
        assert np.all((obj1 != obj2) == [False, True])
        assert np.all((obj2 != obj1) == [False, True])
    
>       assert np.all((obj1 > obj2) == [False, True])
E       TypeError: '>' not supported between instances of 'MaskedColumn' and 'str'

astropy/table/tests/test_column.py:857: TypeError
__________________________________________________ test_unicode_sandwich_compare[list-MaskedColumn] ___________________________________________________

class1 = <class 'astropy.table.column.MaskedColumn'>, class2 = <class 'list'>

    @pytest.mark.parametrize('class1', [table.MaskedColumn, table.Column])
    @pytest.mark.parametrize('class2', [table.MaskedColumn, table.Column, str, list])
    def test_unicode_sandwich_compare(class1, class2):
        """Test that comparing a bytestring Column/MaskedColumn with various
        str (unicode) object types gives the expected result.  Tests #6838.
        """
        obj1 = class1([b'a', b'c'])
        if class2 is str:
            obj2 = 'a'
        elif class2 is list:
            obj2 = ['a', 'b']
        else:
            obj2 = class2(['a', 'b'])
    
        assert np.all((obj1 == obj2) == [True, False])
        assert np.all((obj2 == obj1) == [True, False])
    
        assert np.all((obj1 != obj2) == [False, True])
        assert np.all((obj2 != obj1) == [False, True])
    
>       assert np.all((obj1 > obj2) == [False, True])
E       TypeError: '>' not supported between instances of 'MaskedColumn' and 'list'

astropy/table/tests/test_column.py:857: TypeError
=============================================================== short test summary info ===============================================================
FAILED astropy/table/tests/test_column.py::test_col_unicode_sandwich_unicode - FutureWarning: elementwise comparison failed; returning scalar instea...
FAILED astropy/table/tests/test_column.py::test_unicode_sandwich_compare[MaskedColumn-MaskedColumn] - TypeError: '>' not supported between instances...
FAILED astropy/table/tests/test_column.py::test_unicode_sandwich_compare[Column-MaskedColumn] - TypeError: '>' not supported between instances of 'M...
FAILED astropy/table/tests/test_column.py::test_unicode_sandwich_compare[Column-Column] - FutureWarning: elementwise comparison failed; returning sc...
FAILED astropy/table/tests/test_column.py::test_unicode_sandwich_compare[str-MaskedColumn] - TypeError: '>' not supported between instances of 'Mask...
FAILED astropy/table/tests/test_column.py::test_unicode_sandwich_compare[list-MaskedColumn] - TypeError: '>' not supported between instances of 'Mas...
=============================================== 6 failed, 3377 passed, 43 skipped, 14 xfailed in 25.62s ===============================================

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (20 by maintainers)

Most upvoted comments

@pllim - those other errors are actually due to a bug in Quantity, where the unit of an initial argument is not taken into account (and where units are no longer stripped in numpy). Working on a fix…

I actually don’t know that -dev was changed too - I think they just reverted the bad commit from 1.23, with the idea that for 1.24 there would be a fix (IIRC, https://github.com/numpy/numpy/pull/21812 would solve at least some of the problems)

@pllim - with the corrections to the rc3, i.e., numpy 1.23.x (1.23.0rc3+10.gcc0e08d20), the failures in io.fits, io.misc, and table are all gone – all tests pass! So, we can now move to address the problems in numpy-dev.

ahh, good point, I forgot that the “nightly” is not in fact a daily build, that at least takes the confusion away of how a partial backport could happen that makes the RC fail but the dev still pass.