nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats

Home Page:http://nipy.org/nibabel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-nibabel fails to build with Python 3.13: AttributeError: module 'logging' has no attribute 'warn'; indentation in docstrings mismatch, AssertionError

sanjayankur31 opened this issue · comments

Fedora is testing out our python packages against Python 3.13 which will land in Fedora 41 in a year's time. As part of this, we found a few errors with nibabel:

https://bugzilla.redhat.com/show_bug.cgi?id=2265478

python-nibabel fails to build with Python 3.13.0a4.

FAILED nibabel/tests/test_deprecated.py::TestNibabelDeprecator::test_dep_func
FAILED nibabel/tests/test_deprecator.py::TestDeprecatorFunc::test_dep_func - ...
FAILED nibabel/tests/test_parrec.py::test_diffusion_parameters_strict_sort - ...
FAILED nisext/tests/test_sexts.py::test_package_check - AttributeError: modul...
  1. AttributeError: module 'logging' has no attribute 'warn'
    According to https://docs.python.org/3.13/whatsnew/3.13.html:

logging: Remove undocumented and untested Logger.warn() and LoggerAdapter.warn() methods and logging.warn() function.
Deprecated since Python 3.3, they were aliases to the logging.Logger.warning() method,
logging.LoggerAdapter.warning() method and logging.warning() function.
(Contributed by Victor Stinner in gh-105376.)

>       assert (
            func.__doc__
            == f'A docstring\n   \n   foo\n   \n{indent(TESTSETUP, "   ", lambda x: True)}'
            f'   Some text\n{indent(TESTCLEANUP, "   ", lambda x: True)}'
        )
E       AssertionError: assert 'A docstring\...ne, None)\n\n' == 'A docstring\... None)\n   \n'
E           A docstring
E         -    
E         -    foo
E         -    
E         -    
E         -    
E         + ...
E         
E         ...Full output truncated (43 lines hidden), use '-vv' to show

nibabel/tests/test_deprecator.py:95: AssertionError

Indentation in docstrings is now stripped, the output needs to be adjusted.

>       assert_almost_equal(bvecs, DTI_PAR_BVECS[np.ix_(np.argsort(DTI_PAR_BVALS), [2, 0, 1])])

nibabel/tests/test_parrec.py:536: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.13/contextlib.py:85: in inner
    return func(*args, **kwds)
/usr/lib64/python3.13/contextlib.py:85: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7fd7ce47e8e0>, array([[ 0.   ,  0.   ,  0.   ],
       [-0...., -0.707, -0.   ],
       [ 0.   , -0.707,  0.707],
       [ 0.707, -0.   ,  0.707],
       [ 0.   ,  0.   ,  0.   ]]))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 7 decimals', 'precision': 7, 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Arrays are not almost equal to 7 decimals
E           
E           Mismatched elements: 6 / 24 (25%)
E           Max absolute difference: 1.334
E           Max relative difference: 2.
E            x: array([[ 0.   ,  0.   ,  0.   ],
E                  [-0.333, -0.667, -0.667],
E                  [-0.667, -0.333,  0.667],...
E            y: array([[ 0.   ,  0.   ,  0.   ],
E                  [-0.333, -0.667, -0.667],
E                  [ 0.667, -0.667,  0.333],...

/usr/lib64/python3.13/contextlib.py:85: AssertionError

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/07046875-python-nibabel/

For all our attempts to build python-nibabel with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-nibabel/

It looks like you're building 5.1.0. I think some of these may be addressed in 5.2.

Ah, yes, all of these errors go away with 5.2.0. Closing. Thanks very much.