Skip to content

test_brief failures on 32-bit platforms with numpy2 #7685

@olebole

Description

@olebole

Description:

When we try to rebuild the skimage Debian package for numpy 2 on 32-bit architectures (i386, arm), the tests in skimage/feature/tests/test_brief.py fail:

__________________________ test_normal_mode[float32] ___________________________
dtype = 'float32'

    @pytest.mark.parametrize('dtype', ['float32', 'float64', 'uint8', 'int'])
    def test_normal_mode(dtype):
        """Verify the computed BRIEF descriptors with expected for normal mode."""
        img = data.coins().astype(dtype)
    
        keypoints = corner_peaks(
            corner_harris(img), min_distance=5, threshold_abs=0, threshold_rel=0.1
        )
    
        extractor = BRIEF(descriptor_size=8, sigma=2)
    
>       extractor.extract(img, keypoints[:8])

skimage/feature/tests/test_brief.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <skimage.feature.brief.BRIEF object at 0xe11eb710>
image = array(…, dtype=float32)
keypoints = array([…])

    def extract(self, image, keypoints):
[…]
        # Removing keypoints that are within (patch_size / 2) distance from the
        # image border
        self.mask = _mask_border_keypoints(image.shape, keypoints, patch_size // 2)
    
>       keypoints = np.array(
            keypoints[self.mask, :], dtype=np.int64, order='C', copy=False
        )
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

skimage/feature/brief.py:201: ValueError

This was reported as Debian#1094689. Full build log here

Removing the copy=False argument lets the tests pass, and from the migration guide it seems that skimage here falls under the first, "Older code" argument - the copy argument is there since at least 12 years.

Way to reproduce:

Run the CI test on a 32-bit platform using numpy 2.2.

Version information:

* Python 3.13.1 and 3.12.8
* Kernel: Linux 6.1.0-30-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.124-1 (2025-01-12) amd64 (x86_64)
* skimage 0.24.0 and 0.25.1
* numpy 2.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions