Skip to content

Cython3 chokes on astropy 5.3.3 (worked in 5.3.2) #15315

Description

@bnavigator

Description

For the openSUSE Tumbleweed rpm package, we have been ignoring the exact version pin for Cython

"cython==0.29.34",

... and ran into a test failure possibly related to #15076 and #15049

>>> astropy.test(args="-k w0wzCDM")
========================================================================= test session starts =========================================================================
platform linux -- Python 3.11.5, pytest-7.4.0, pluggy-1.0.0

Running tests with Astropy version 5.3.3.
Running tests in /usr/lib64/python3.11/site-packages/astropy.

Date: 2023-09-14T09:56:22

Platform: Linux-6.4.11-1-default-x86_64-with-glibc2.38

Executable: /usr/bin/python3.11

Full Python Version: 
3.11.5 (main, Aug 31 2023, 07:57:41) [GCC]

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

Package versions: 
Numpy: 1.25.2
Scipy: 1.11.1
Matplotlib: 3.6.3
h5py: 3.9.0
Pandas: 2.1.0
PyERFA: 2.0.0.3
Cython: 3.0.2
Scikit-image: not available
asdf: 2.15.1

Using Astropy options: remote_data: none.

Matplotlib: 3.6.3
Freetype: 2.6.1
rootdir: /usr/lib64/python3.11/site-packages/astropy
plugins: asdf-2.15.1, hypothesis-6.82.7, astropy-header-0.2.2, filter-subpackage-0.1.2, arraydiff-0.5.0, openfiles-0.5.0, remotedata-0.4.0, doctestplus-0.13.0, mock-3.11.1, cov-4.1.0, mpl-0.12, astropy-0.10.0, xdist-3.3.1
collected 27491 items / 26843 deselected / 3 skipped / 648 selected                                                                                                   

../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py ...................................E.EEEE................................ [ 11%]
............................................................................................................................................................... [ 35%]
.....................................................................................E.......................................E.EEEE............................ [ 60%]
........................................................................................................E...................................................... [ 84%]
.................................................................................................                                                               [ 99%]
../../usr/lib64/python3.11/site-packages/astropy/cosmology/funcs/tests/test_funcs.py .                                                                          [100%]

=============================================================================== ERRORS ================================================================================
___________________________________________________ ERROR at setup of Testw0wzCDM.test_tofromformat_model_instance ____________________________________________________

self = <astropy.cosmology.flrw.tests.test_w0wzcdm.Testw0wzCDM object at 0x7f8ade04c810>
cosmo = w0wzCDM(name="ABCMeta", H0=70.0 km / (Mpc s), Om0=0.27, Ode0=0.73, w0=-1.0, wz=0.5, Tcmb0=3.0 K, Neff=3.04, m_nu=[0. 0. 0.] eV, Ob0=0.03)

    @pytest.fixture(scope="class")
    def method_name(self, cosmo):
        # get methods, ignoring private and dunder
        methods = get_redshift_methods(cosmo, include_private=False, include_z2=True)
    
        # dynamically detect ABC and optional dependencies
        for n in tuple(methods):
            params = inspect.signature(getattr(cosmo, n)).parameters.keys()
    
            ERROR_SEIVE = (NotImplementedError, ValueError)
            #              # ABC                can't introspect for good input
            if not HAS_SCIPY:
                ERROR_SEIVE = ERROR_SEIVE + (ModuleNotFoundError,)
    
            args = np.arange(len(params)) + 1
            try:
>               getattr(cosmo, n)(*args)

/usr/lib64/python3.11/site-packages/astropy/cosmology/io/tests/test_model.py:49: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/base.py:1017: in age
    return self._age(z)
/usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/base.py:1034: in _age
    return self._hubble_time * self._integral_age(z)
/usr/lib64/python3.11/site-packages/astropy/cosmology/utils.py:55: in wrapper
    return func(self, *zs, *args[nin:], **kwargs)
/usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/base.py:1057: in _integral_age
    return quad(self._lookback_time_integrand_scalar, z, inf)[0]
/usr/lib64/python3.11/site-packages/scipy/integrate/_quadpack_py.py:465: in quad
    retval = _quad(func, a, b, args, full_output, epsabs, epsrel, limit,
/usr/lib64/python3.11/site-packages/scipy/integrate/_quadpack_py.py:579: in _quad
    return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
/usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/base.py:823: in _lookback_time_integrand_scalar
    return self._inv_efunc_scalar(z, *self._inv_efunc_scalar_args) / (z + 1.0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   TypeError: must be real number, not complex

astropy/cosmology/flrw/scalar_inv_efuncs.pyx:217: TypeError
_

...

======================================================================= short test summary info =======================================================================
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_tofromformat_model_instance - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_is_equivalent_to_model[True] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_is_equivalent_to_model[False] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_is_equivalent_to_model[None] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_is_equivalent_to_model[astropy.model] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::Testw0wzCDM::test_toformat_model - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_tofromformat_model_instance - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_is_equivalent_to_model[True] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_is_equivalent_to_model[False] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_is_equivalent_to_model[None] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_is_equivalent_to_model[astropy.model] - TypeError: must be real number, not complex
ERROR ../../usr/lib64/python3.11/site-packages/astropy/cosmology/flrw/tests/test_w0wzcdm.py::TestFlatw0wzCDM::test_toformat_model - TypeError: must be real number, not complex
============================================== 636 passed, 3 skipped, 26843 deselected, 4 warnings, 12 errors in 21.35s ===============================================
<ExitCode.TESTS_FAILED: 1>

Restraining the build to Cython < 3 helped us.

Expected behavior

Passing test suite

How to Reproduce

  1. Build astropy 5.3.3 with Cython 3
  2. Run tests
import astropy
astropy.test(args="-k w0wzCDM")

Versions

>>> import platform; print(platform.platform())
Linux-6.4.11-1-default-x86_64-with-glibc2.38
>>> import sys; print("Python", sys.version)
Python 3.11.5 (main, Aug 31 2023, 07:57:41) [GCC]
>>> import astropy; print("astropy", astropy.__version__)
astropy 5.3.3
>>> import numpy; print("Numpy", numpy.__version__)
Numpy 1.25.2
>>> import erfa; print("pyerfa", erfa.__version__)
pyerfa 2.0.0.3
>>> import scipy; print("Scipy", scipy.__version__)
Scipy 1.11.1
>>> import matplotlib; print("Matplotlib", matplotlib.__version__)
Matplotlib 3.6.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions