Bug 2424321

Summary: scipy fails to build with Python 3.15: AssertionError: Not equal to tolerance rtol=0.03125, atol=0
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: scipyAssignee: Nikola Forró <nforro>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, david08741, ksurma, mhroncok, nforro, psimovec, python-packagers-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-01-23 16:13:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2412434    

Description Karolina Surma 2025-12-22 16:15:47 UTC
scipy fails to build with Python 3.15.0a3.

_______________ TestDerivative.test_dtype[numpy-float16-0.65--1] _______________
[gw0] linux -- Python 3.15.0 /usr/bin/python3

self = <scipy.differentiate.tests.test_differentiate.TestDerivative object at 0x7f6c12969130>
hdir = -1, x = array(0.65, dtype=float16), dtype = <class 'numpy.float16'>
xp = <module 'scipy._lib.array_api_compat.numpy' from '/builddir/build/BUILD/scipy-1.16.2-build/BUILDROOT/usr/lib64/python3.15/site-packages/scipy/_lib/array_api_compat/numpy/__init__.py'>

    @pytest.mark.parametrize("hdir", (-1, 0, 1))
    @pytest.mark.parametrize("x", (0.65, [0.65, 0.7]))
    @pytest.mark.parametrize("dtype", ('float16', 'float32', 'float64'))
    def test_dtype(self, hdir, x, dtype, xp):
        if dtype == 'float16' and not is_numpy(xp):
            pytest.skip('float16 not tested for alternative backends')
    
        # Test that dtypes are preserved
        dtype = getattr(xp, dtype)
        x = xp.asarray(x, dtype=dtype)
    
        def f(x):
            assert x.dtype == dtype
            return xp.exp(x)
    
        def callback(res):
            assert res.x.dtype == dtype
            assert res.df.dtype == dtype
            assert res.error.dtype == dtype
    
        res = derivative(f, x, order=4, step_direction=hdir, callback=callback)
        assert res.x.dtype == dtype
        assert res.df.dtype == dtype
        assert res.error.dtype == dtype
        eps = xp.finfo(dtype).eps
        # not sure why torch is less accurate here; might be worth investigating
        rtol = eps**0.5 * 50 if is_torch(xp) else eps**0.5
>       xp_assert_close(res.df, xp.exp(res.x), rtol=rtol)
E       AssertionError: 
E       Not equal to tolerance rtol=0.03125, atol=0
E       
E       Mismatched elements: 1 / 1 (100%)
E       Max absolute difference among violations: 0.296
E       Max relative difference among violations: 0.1545
E        ACTUAL: array(2.21, dtype=float16)
E        DESIRED: array(1.915, dtype=float16)

scipy/differentiate/tests/test_differentiate.py:328: AssertionError
________________ TestDerivative.test_dtype[numpy-float16-x1--1] ________________
[gw0] linux -- Python 3.15.0 /usr/bin/python3

self = <scipy.differentiate.tests.test_differentiate.TestDerivative object at 0x7f6c12969310>
hdir = -1, x = array([0.65, 0.7 ], dtype=float16)
dtype = <class 'numpy.float16'>
xp = <module 'scipy._lib.array_api_compat.numpy' from '/builddir/build/BUILD/scipy-1.16.2-build/BUILDROOT/usr/lib64/python3.15/site-packages/scipy/_lib/array_api_compat/numpy/__init__.py'>

    @pytest.mark.parametrize("hdir", (-1, 0, 1))
    @pytest.mark.parametrize("x", (0.65, [0.65, 0.7]))
    @pytest.mark.parametrize("dtype", ('float16', 'float32', 'float64'))
    def test_dtype(self, hdir, x, dtype, xp):
        if dtype == 'float16' and not is_numpy(xp):
            pytest.skip('float16 not tested for alternative backends')
    
        # Test that dtypes are preserved
        dtype = getattr(xp, dtype)
        x = xp.asarray(x, dtype=dtype)
    
        def f(x):
            assert x.dtype == dtype
            return xp.exp(x)
    
        def callback(res):
            assert res.x.dtype == dtype
            assert res.df.dtype == dtype
            assert res.error.dtype == dtype
    
        res = derivative(f, x, order=4, step_direction=hdir, callback=callback)
        assert res.x.dtype == dtype
        assert res.df.dtype == dtype
        assert res.error.dtype == dtype
        eps = xp.finfo(dtype).eps
        # not sure why torch is less accurate here; might be worth investigating
        rtol = eps**0.5 * 50 if is_torch(xp) else eps**0.5
>       xp_assert_close(res.df, xp.exp(res.x), rtol=rtol)
E       AssertionError: 
E       Not equal to tolerance rtol=0.03125, atol=0
E       
E       Mismatched elements: 1 / 2 (50%)
E       Max absolute difference among violations: 0.296
E       Max relative difference among violations: 0.1545
E        ACTUAL: array([2.21 , 1.996], dtype=float16)
E        DESIRED: array([1.915, 2.014], dtype=float16)

scipy/differentiate/tests/test_differentiate.py:328: AssertionError
________________ TestDerivative.test_dtype[numpy-float16-x1-1] _________________
[gw0] linux -- Python 3.15.0 /usr/bin/python3

self = <scipy.differentiate.tests.test_differentiate.TestDerivative object at 0x7f6c12969450>
hdir = 1, x = array([0.65, 0.7 ], dtype=float16)
dtype = <class 'numpy.float16'>
xp = <module 'scipy._lib.array_api_compat.numpy' from '/builddir/build/BUILD/scipy-1.16.2-build/BUILDROOT/usr/lib64/python3.15/site-packages/scipy/_lib/array_api_compat/numpy/__init__.py'>

    @pytest.mark.parametrize("hdir", (-1, 0, 1))
    @pytest.mark.parametrize("x", (0.65, [0.65, 0.7]))
    @pytest.mark.parametrize("dtype", ('float16', 'float32', 'float64'))
    def test_dtype(self, hdir, x, dtype, xp):
        if dtype == 'float16' and not is_numpy(xp):
            pytest.skip('float16 not tested for alternative backends')
    
        # Test that dtypes are preserved
        dtype = getattr(xp, dtype)
        x = xp.asarray(x, dtype=dtype)
    
        def f(x):
            assert x.dtype == dtype
            return xp.exp(x)
    
        def callback(res):
            assert res.x.dtype == dtype
            assert res.df.dtype == dtype
            assert res.error.dtype == dtype
    
        res = derivative(f, x, order=4, step_direction=hdir, callback=callback)
        assert res.x.dtype == dtype
        assert res.df.dtype == dtype
        assert res.error.dtype == dtype
        eps = xp.finfo(dtype).eps
        # not sure why torch is less accurate here; might be worth investigating
        rtol = eps**0.5 * 50 if is_torch(xp) else eps**0.5
>       xp_assert_close(res.df, xp.exp(res.x), rtol=rtol)
E       AssertionError: 
E       Not equal to tolerance rtol=0.03125, atol=0
E       
E       Mismatched elements: 1 / 2 (50%)
E       Max absolute difference among violations: 2.268
E       Max relative difference among violations: 1.126
E        ACTUAL: array([1.894, 4.28 ], dtype=float16)
E        DESIRED: array([1.915, 2.014], dtype=float16)

FAILED scipy/differentiate/tests/test_differentiate.py::TestDerivative::test_dtype[numpy-float16-0.65--1]
FAILED scipy/differentiate/tests/test_differentiate.py::TestDerivative::test_dtype[numpy-float16-x1--1]
FAILED scipy/differentiate/tests/test_differentiate.py::TestDerivative::test_dtype[numpy-float16-x1-1]

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/09929862-scipy/

For all our attempts to build scipy with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/scipy/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Charalampos Stratakis 2026-01-23 16:13:56 UTC
These are COPR specific failures, not related to Python 3.15.