• Bug#1109953: nibabel: tests failing with scipy 1.16

    From Drew Parsons@21:1/5 to All on Sun Jul 27 10:30:01 2025
    Source: nibabel
    Version: 5.3.2-2
    Severity: normal

    scipy 1.16 has been uploaded to experimental.
    nibabel tests are failing with it, possibly due to a change in API.

    176s =========================== short test summary info ============================
    176s FAILED nibabel/tests/test_processing.py::test_resample_from_to - Failed: DID ...
    176s FAILED nibabel/tests/test_processing.py::test_resample_to_output - Failed: DI...
    176s = 2 failed, 5362 passed, 108 skipped, 11 xfailed, 1 xpassed, 26950 warnings in 137.68s (0:02:17) =

    nibabel is expecting a UserWarning which is not emitted, so test_resample* fails:

    176s ___________________________ test_resample_to_output ____________________________
    176s
    176s caplog = <_pytest.logging.LogCaptureFixture object at 0x7fb89afd3110>
    176s
    176s @needs_scipy
    176s def test_resample_to_output(caplog):
    176s # Test routine to sample images to output space
    176s # Image aligned to output axes - no-op
    176s data = np.arange(24, dtype='int32').reshape((2, 3, 4))
    176s img = Nifti1Image(data, np.eye(4))
    176s # Check default resampling
    176s img2 = resample_to_output(img)
    176s assert_array_equal(img2.shape, (2, 3, 4))
    176s assert_array_equal(img2.affine, np.eye(4))
    176s assert_array_equal(img2.dataobj, data)
    176s # Check resampling with different voxel size specifications
    176s for vox_sizes in (None, 1, [1, 1, 1]):
    176s img2 = resample_to_output(img, vox_sizes)
    176s assert_array_equal(img2.shape, (2, 3, 4))
    176s assert_array_equal(img2.affine, np.eye(4))
    176s assert_array_equal(img2.dataobj, data)
    176s img2 = resample_to_output(img, vox_sizes)
    176s # Check 2D works
    176s img_2d = Nifti1Image(data[0], np.eye(4))
    176s for vox_sizes in (None, 1, (1, 1), (1, 1, 1)):
    176s img3 = resample_to_output(img_2d, vox_sizes)
    176s assert_array_equal(img3.shape, (3, 4, 1))
    176s assert_array_equal(img3.affine, np.eye(4))
    176s assert_array_equal(img3.dataobj, data[0][..., None])
    176s # Even 1D
    176s img_1d = Nifti1Image(data[0, 0], np.eye(4))
    176s img3 = resample_to_output(img_1d)
    176s assert_array_equal(img3.shape, (4, 1, 1))
    176s assert_array_equal(img3.affine, np.eye(4))
    176s assert_array_equal(img3.dataobj, data[0, 0][..., None, None])
    176s # But 4D does not
    176s img_4d = Nifti1Image(data.reshape(2, 3, 2, 2), np.eye(4))
    176s with pytest.raises(ValueError):
    176s resample_to_output(img_4d)
    176s # Run vox2vox_out tests, checking output shape, coordinate transform
    176s for in_shape, in_aff, vox, out_shape, out_aff in get_outspace_params():
    176s # Allow for expansion of image shape from < 3D
    176s in_n_dim = len(in_shape)
    176s if in_n_dim < 3:
    176s in_shape = in_shape + (1,) * (3 - in_n_dim)
    176s if not vox is None:
    176s vox = vox + (1,) * (3 - in_n_dim)
    176s assert len(out_shape) == in_n_dim
    176s out_shape = out_shape + (1,) * (3 - in_n_dim)
    176s img = Nifti1Image(np.ones(in_shape), in_aff)
    176s out_img = resample_to_output(img, vox)
    176s assert_all_in(in_shape, in_aff, out_img.shape, out_img.affine) 176s assert out_img.shape == out_shape
    176s assert_almost_equal(out_img.affine, out_aff)
    176s # Check data is as expected with some transforms
    176s # Flip first axis
    176s out_img = resample_to_output(Nifti1Image(data, np.diag([-1, 1, 1, 1])))
    176s assert_array_equal(out_img.dataobj, np.flipud(data))
    176s # Subsample voxels
    176s out_img = resample_to_output(Nifti1Image(data, np.diag([4, 5, 6, 1])))
    176s > with pytest.warns(UserWarning): # Suppress scipy warning
    176s E Failed: DID NOT WARN. No warnings of type (<class 'UserWarning'>,) were emitted.
    176s E Emitted warnings: [].
    176s
    176s nibabel/tests/test_processing.py:278: Failed


    This bug will become RC serious later, after scipy 1.16 is uploaded to unstable.


    -- System Information:
    Debian Release: 13.0
    APT prefers unstable-debug
    APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64)
    Foreign Architectures: i386

    Kernel: Linux 6.12.38+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
    Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)