Skip to content

Test failures with Python 3.12 and astropy 5.3.2 #15238

Closed

Description

@sergiopasra

Description

I'm building astropy 5.3.2 with python 3.12.0 rc1 inside the Fedora infrastructure and I'm getting errors in the following tests:

astropy/io/votable/tests/vo_test.py
astropy/nddata/mixins/tests/test_ndslicing.py
astropy/table/tests/test_table.py

=================================== FAILURES ===================================
____________________________ test_gzip_filehandles _____________________________

tmp_path = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_gzip_filehandles0')

    def test_gzip_filehandles(tmp_path):
        with np.errstate(over="ignore"):
            # https://github.com/astropy/astropy/issues/13341
            votable = parse(get_pkg_data_filename("data/regression.xml"))
    
        # W39: Bit values can not be masked
        with pytest.warns(W39):
            with open(tmp_path / "regression.compressed.xml", "wb") as fd:
                votable.to_xml(fd, compressed=True, _astropy_version="testing")
    
        with open(tmp_path / "regression.compressed.xml", "rb") as fd:
>           votable = parse(fd)

astropy/io/votable/tests/vo_test.py:855: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/utils/decorators.py:604: in wrapper
    return function(*args, **kwargs)
astropy/io/votable/table.py:177: in parse
    return tree.VOTableFile(config=config, pos=(1, 1)).parse(iterator, config)
astropy/io/votable/tree.py:3858: in parse
    for start, tag, data, pos in iterator:
/usr/lib64/python3.12/gzip.py:324: in read
    return self._buffer.read(size)
/usr/lib64/python3.12/_compression.py:68: in readinto
    data = self.read(len(byte_view))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <gzip._GzipReader object at 0x7f75bd008730>, size = 8192

    def read(self, size=-1):
        if size < 0:
            return self.readall()
        # size=0 is special because decompress(max_length=0) is not supported
        if not size:
            return b""
    
        # For certain input data, a single
        # call to decompress() may not return
        # any data. In this case, retry until we get some data or reach EOF.
        while True:
            if self._decompressor.eof:
                # Ending case: we've come to the end of a member in the file,
                # so finish up this member, and read a new gzip header.
                # Check the CRC and file size, and set the flag so we read
                # a new member
                self._read_eof()
                self._new_member = True
                self._decompressor = self._decomp_factory(
                    **self._decomp_args)
    
            if self._new_member:
                # If the _new_member flag is set, we have to
                # jump to the next member, if there is one.
                self._init_read()
                if not self._read_gzip_header():
                    self._size = self._pos
                    return b""
                self._new_member = False
    
            # Read a chunk of data from the file
            if self._decompressor.needs_input:
                buf = self._fp.read(READ_BUFFER_SIZE)
                uncompress = self._decompressor.decompress(buf, size)
            else:
                uncompress = self._decompressor.decompress(b"", size)
    
            if self._decompressor.unused_data != b"":
                # Prepend the already read bytes to the fileobj so they can
                # be seen by _read_eof() and _read_gzip_header()
                self._fp.prepend(self._decompressor.unused_data)
    
            if uncompress != b"":
                break
            if buf == b"":
>               raise EOFError("Compressed file ended before the "
                               "end-of-stream marker was reached")
E               EOFError: Compressed file ended before the end-of-stream marker was reached

/usr/lib64/python3.12/gzip.py:544: EOFError
_______________________ test_slicing_all_something_wrong _______________________

    def test_slicing_all_something_wrong():
        data = np.arange(10)
        mask = [False] * 10
        uncertainty = UnknownUncertainty({"rdnoise": 2.9, "gain": 1.4})
        naxis = 1
        wcs = nd_testing._create_wcs_simple(
            naxis=naxis,
            ctype=["deg"] * naxis,
            crpix=[3] * naxis,
            crval=[10] * naxis,
            cdelt=[1] * naxis,
        )
    
        nd = NDDataSliceable(data, mask=mask, uncertainty=uncertainty, wcs=wcs)
>       nd2 = nd[2:5]

astropy/nddata/mixins/tests/test_ndslicing.py:171: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/nddata/mixins/ndslicing.py:64: in __getitem__
    kwargs = self._slice(item)
astropy/nddata/mixins/ndslicing.py:92: in _slice
    kwargs["uncertainty"] = self._slice_uncertainty(item)
astropy/nddata/mixins/ndslicing.py:104: in _slice_uncertainty
    return self.uncertainty[item]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = UnknownUncertainty({'rdnoise': 2.9, 'gain': 1.4})
item = slice(2, 5, None)

    def __getitem__(self, item):
        """Normal slicing on the array, keep the unit and return a reference."""
>       return self.__class__(self.array[item], unit=self.unit, copy=False)
E       KeyError: slice(2, 5, None)

astropy/nddata/nduncertainty.py:331: KeyError
__________________________ test_table_attribute_fail ___________________________

    def test_table_attribute_fail():
        # Code raises ValueError(f'{attr} not allowed as TableAttribute') but in this
        # context it gets re-raised as a RuntimeError during class definition.
        with pytest.raises(RuntimeError, match="Error calling __set_name__"):
    
>           class MyTable2(Table):

astropy/table/tests/test_table.py:2900: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'TableAttribute' object has no attribute 'name'") raised in repr()] TableAttribute object at 0x7f75bb5f2cc0>
owner = <class 'astropy.table.tests.test_table.test_table_attribute_fail.<locals>.MyTable2'>
name = 'descriptions'

    def __set_name__(self, owner, name):
        import inspect
    
        params = [
            param.name
            for param in inspect.signature(owner).parameters.values()
            if param.kind
            not in (inspect.Parameter.VAR_KEYWORD, inspect.Parameter.VAR_POSITIONAL)
        ]
    
        # Reject names from existing params or best guess at parent class
        if name in params or hasattr(owner.__mro__[1], name):
>           raise ValueError(f"{name} not allowed as {self.__class__.__name__}")
E           ValueError: descriptions not allowed as TableAttribute
E           Error calling __set_name__ on 'TableAttribute' instance 'descriptions' in 'MyTable2'

astropy/utils/metadata.py:537: ValueError

Expected behavior

Tests should pass

How to Reproduce

Build with python 3.12

Versions

Python 3.12.0rc1 (main, Aug 7 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]

encodings: sys: utf-8, locale: utf-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Package versions:
Numpy: 1.24.4
Scipy: 1.11.1
Matplotlib: 3.7.2
h5py: 3.8.0
Pandas: 1.5.3
PyERFA: 2.0.0.3
Cython: 3.0.0
Scikit-image: 0.21.0

Activity

  1. changed the title [-]Test failures with Python 3.12 and astropy 5.3.1[/-] [+]Test failures with Python 3.12 and astropy 5.3.2[/+] on Aug 28, 2023
  2. pllim commented on Aug 28, 2023

    @pllim
  3. pllim commented on Aug 31, 2023

    @pllim
    Member

    Update: Indeed now I see these failures (and a bit more) over at #14784 . Suggestions on how to fix is welcome. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions