Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with NumPy 2.0.0rc1 #1077

Open
mgorny opened this issue Apr 22, 2024 · 2 comments
Open

Test failures with NumPy 2.0.0rc1 #1077

mgorny opened this issue Apr 22, 2024 · 2 comments

Comments

@mgorny
Copy link
Contributor

mgorny commented Apr 22, 2024

When running the test suite against NumPy 2.0.0rc1, I'm getting the following test failures (and warnings):

========================================================= test session starts =========================================================
platform linux -- Python 3.11.9, pytest-8.1.1, pluggy-1.5.0
rootdir: /tmp/imageio
plugins: cov-5.0.0
collected 318 items / 3 skipped                                                                                                       

tests/test_bsdf.py ........                                                                                                     [  2%]
tests/test_config.py .                                                                                                          [  2%]
tests/test_core.py .......F.................................................                                                    [ 20%]
tests/test_dicom.py ..F...F.                                                                                                    [ 23%]
tests/test_fei_tiff.py ..                                                                                                       [ 23%]
tests/test_ffmpeg.py .................x.xx....                                                                                  [ 31%]
tests/test_ffmpeg_info.py ..                                                                                                    [ 32%]
tests/test_format.py .............                                                                                              [ 36%]
tests/test_freeimage.py ..............s....                                                                                     [ 42%]
tests/test_grab.py ..                                                                                                           [ 43%]
tests/test_legacy_plugin_wrapper.py ...                                                                                         [ 44%]
tests/test_lytro.py ........                                                                                                    [ 46%]
tests/test_meta.py ...                                                                                                          [ 47%]
tests/test_npz.py ..                                                                                                            [ 48%]
tests/test_pillow.py ................................................                                                           [ 63%]
tests/test_pillow_legacy.py .....xx.......                                                                                      [ 67%]
tests/test_pyav.py .........................x....                                                                               [ 77%]
tests/test_simpleitk.py s                                                                                                       [ 77%]
tests/test_spe.py ......                                                                                                        [ 79%]
tests/test_swf.py ......                                                                                                        [ 81%]
tests/test_tifffile.py ....................                                                                                     [ 87%]
tests/test_tifffile_v3.py ...............................                                                                       [ 97%]
tests/test_v2.py .........                                                                                                      [100%]

============================================================== FAILURES ===============================================================
___________________________________________________________ test_util_image ___________________________________________________________

    def test_util_image():
        meta = {"foo": 3, "bar": {"spam": 1, "eggs": 2}}
        # Image
        a = np.zeros((10, 10))
        im = core.util.Image(a, meta)
        isinstance(im, np.ndarray)
        isinstance(im.meta, dict)
        assert str(im) == str(a)
        # Preserve after copy
        im2 = core.util.Image(im)
        assert isinstance(im2, core.util.Image)
        assert im2.meta == im.meta
        # Preserve after action
        im2 = im + 1
>       assert isinstance(im2, core.util.Image)
E       AssertionError: assert False
E        +  where False = isinstance(array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],\n       [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],\n       [1., 1., 1., ...1., 1., 1., 1., 1.],\n       [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],\n       [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]), <class 'imageio.core.util.Array'>)
E        +    where <class 'imageio.core.util.Array'> = <module 'imageio.core.util' from '/tmp/imageio/imageio/core/util.py'>.Image
E        +      where <module 'imageio.core.util' from '/tmp/imageio/imageio/core/util.py'> = core.util

tests/test_core.py:390: AssertionError
___________________________________________________________ test_selection ____________________________________________________________

test_images = PosixPath('/tmp/imageio/.test_images'), tmp_path = PosixPath('/tmp/pytest-of-mgorny/pytest-2/test_selection0')
examples = (PosixPath('/tmp/pytest-of-mgorny/pytest-2/test_dicom/dicom_sample1'), PosixPath('/tmp/pytest-of-mgorny/pytest-2/test_....656.1.138.100.dcm', '/tmp/pytest-of-mgorny/pytest-2/test_dicom/dicom_sample2/1.2.826.0.1.3680043.2.656.1.138.100.dcm')

    @deprecated_test
    def test_selection(test_images, tmp_path, examples):
        dname1, dname2, fname1, fname2 = examples
    
        # Test that DICOM can examine file
        F = iio.formats.search_read_format(core.Request(fname1, "ri"))
        assert F.name == "DICOM"
        assert isinstance(F, type(iio.formats["DICOM"]))
    
        # Test that we cannot save
        request = core.Request(tmp_path / "test.dcm", "wi")
        assert not F.can_write(request)
    
        # Test fail on wrong file
        fname2 = fname1 + ".fake"
        bb = open(fname1, "rb").read()
        bb = bb[:128] + b"XXXX" + bb[132:]
        open(fname2, "wb").write(bb)
        with pytest.raises(Exception):
            F.get_reader(core.Request(fname2, "ri"))
    
        # Test special files with other formats
>       im = iio.imread(test_images / "dicom_file01.dcm")

tests/test_dicom.py:79: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
imageio/v2.py:360: in imread
    result = file.read(index=0, **kwargs)
imageio/core/legacy_plugin_wrapper.py:147: in read
    reader = self.legacy_get_reader(**kwargs)
imageio/core/legacy_plugin_wrapper.py:116: in legacy_get_reader
    return self._format.get_reader(self._request)
imageio/core/format.py:221: in get_reader
    return self.Reader(self, request)
imageio/core/format.py:312: in __init__
    self._open(**self.request.kwargs.copy())
imageio/plugins/dicom.py:190: in _open
    self._data = dcm.get_numpy_array()
imageio/plugins/_dicom.py:409: in get_numpy_array
    data = self._apply_slope_and_offset(data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <imageio.plugins._dicom.SimpleDicomReader object at 0x7fcec74e1f50>
data = array([[44, 44, 46, ..., 13,  4,  2],
       [41, 43, 41, ...,  9,  8,  4],
       [40, 42, 43, ...,  5, 10, 14],
    ...5, 37, 42, ..., 29, 31, 36],
       [40, 40, 37, ..., 25, 30, 32],
       [43, 39, 35, ..., 21, 24, 27]], dtype=uint16)

    def _apply_slope_and_offset(self, data):
        """
        If RescaleSlope and RescaleIntercept are present in the data,
        apply them. The data type of the data is changed if necessary.
        """
        # Obtain slope and offset
        slope, offset = 1, 0
        needFloats, needApplySlopeOffset = False, False
        if "RescaleSlope" in self:
            needApplySlopeOffset = True
            slope = self.RescaleSlope
        if "RescaleIntercept" in self:
            needApplySlopeOffset = True
            offset = self.RescaleIntercept
        if int(slope) != slope or int(offset) != offset:
            needFloats = True
        if not needFloats:
            slope, offset = int(slope), int(offset)
    
        # Apply slope and offset
        if needApplySlopeOffset:
            # Maybe we need to change the datatype?
            if data.dtype in [np.float32, np.float64]:
                pass
            elif needFloats:
                data = data.astype(np.float32)
            else:
                # Determine required range
                minReq, maxReq = data.min(), data.max()
>               minReq = min([minReq, minReq * slope + offset, maxReq * slope + offset])
E               OverflowError: Python integer -1024 out of bounds for uint16

imageio/plugins/_dicom.py:535: OverflowError
___________________________________________________________ test_v3_reading ___________________________________________________________

test_images = PosixPath('/tmp/imageio/.test_images')

    def test_v3_reading(test_images):
        # this is a regression test for
        # https://github.com/imageio/imageio/issues/862
>       expected = iio.imread(test_images / "dicom_file01.dcm")

tests/test_dicom.py:190: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
imageio/v2.py:360: in imread
    result = file.read(index=0, **kwargs)
imageio/core/legacy_plugin_wrapper.py:147: in read
    reader = self.legacy_get_reader(**kwargs)
imageio/core/legacy_plugin_wrapper.py:116: in legacy_get_reader
    return self._format.get_reader(self._request)
imageio/core/format.py:221: in get_reader
    return self.Reader(self, request)
imageio/core/format.py:312: in __init__
    self._open(**self.request.kwargs.copy())
imageio/plugins/dicom.py:190: in _open
    self._data = dcm.get_numpy_array()
imageio/plugins/_dicom.py:409: in get_numpy_array
    data = self._apply_slope_and_offset(data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <imageio.plugins._dicom.SimpleDicomReader object at 0x7fcec74df850>
data = array([[44, 44, 46, ..., 13,  4,  2],
       [41, 43, 41, ...,  9,  8,  4],
       [40, 42, 43, ...,  5, 10, 14],
    ...5, 37, 42, ..., 29, 31, 36],
       [40, 40, 37, ..., 25, 30, 32],
       [43, 39, 35, ..., 21, 24, 27]], dtype=uint16)

    def _apply_slope_and_offset(self, data):
        """
        If RescaleSlope and RescaleIntercept are present in the data,
        apply them. The data type of the data is changed if necessary.
        """
        # Obtain slope and offset
        slope, offset = 1, 0
        needFloats, needApplySlopeOffset = False, False
        if "RescaleSlope" in self:
            needApplySlopeOffset = True
            slope = self.RescaleSlope
        if "RescaleIntercept" in self:
            needApplySlopeOffset = True
            offset = self.RescaleIntercept
        if int(slope) != slope or int(offset) != offset:
            needFloats = True
        if not needFloats:
            slope, offset = int(slope), int(offset)
    
        # Apply slope and offset
        if needApplySlopeOffset:
            # Maybe we need to change the datatype?
            if data.dtype in [np.float32, np.float64]:
                pass
            elif needFloats:
                data = data.astype(np.float32)
            else:
                # Determine required range
                minReq, maxReq = data.min(), data.max()
>               minReq = min([minReq, minReq * slope + offset, maxReq * slope + offset])
E               OverflowError: Python integer -1024 out of bounds for uint16

imageio/plugins/_dicom.py:535: OverflowError
========================================================== warnings summary ===========================================================
tests/test_bsdf.py::test_singleton
  /tmp/imageio/tests/test_bsdf.py:78: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(im1 == im2)

tests/test_bsdf.py::test_singleton
  /tmp/imageio/tests/test_bsdf.py:82: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert len(ims) == 1 and np.all(im1 == ims[0])

tests/test_bsdf.py::test_series
  /tmp/imageio/tests/test_bsdf.py:111: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(im1 == im2)

tests/test_bsdf.py::test_series
tests/test_bsdf.py::test_series
tests/test_bsdf.py::test_series
  /tmp/imageio/tests/test_bsdf.py:115: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert len(ims2) == 3 and all(np.all(ims1[i] == ims2[i]) for i in range(3))

tests/test_bsdf.py::test_series
tests/test_bsdf.py::test_series
tests/test_bsdf.py::test_series
  /tmp/imageio/tests/test_bsdf.py:120: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert len(ims3) == 3 and all(np.all(ims1[i] == ims3[i]) for i in range(3))

tests/test_bsdf.py::test_series_unclosed
tests/test_bsdf.py::test_series_unclosed
tests/test_bsdf.py::test_series_unclosed
  /tmp/imageio/tests/test_bsdf.py:144: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert len(ims2) == 3 and all(np.all(ims1[i] == ims2[i]) for i in range(3))

tests/test_bsdf.py::test_series_unclosed
  /tmp/imageio/tests/test_bsdf.py:150: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(ims1[2] == r.get_data(2))

tests/test_bsdf.py::test_random_access
tests/test_bsdf.py::test_random_access
tests/test_bsdf.py::test_random_access
tests/test_bsdf.py::test_random_access
tests/test_bsdf.py::test_random_access
tests/test_bsdf.py::test_random_access
  /tmp/imageio/tests/test_bsdf.py:164: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(ims1[i] == r.get_data(i))

tests/test_bsdf.py::test_volume
  /tmp/imageio/tests/test_bsdf.py:180: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(vol1 == vol2)

tests/test_core.py::test_util_image
  /tmp/imageio/tests/test_core.py:389: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    im2 = im + 1

tests/test_core.py::test_imopen_extension_malformatted[.jpg]
  /tmp/imageio/imageio/core/request.py:266: DeprecationWarning: The usage of `format_hint` is deprecated and will be removed in ImageIO v3. Use `extension` instead.
    warnings.warn(

tests/test_dicom.py::test_different_read_modes
tests/test_dicom.py::test_different_read_modes
  /tmp/imageio/tests/test_dicom.py:136: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (vol == vol2).all()

tests/test_fei_tiff.py::test_fei_file_reading
tests/test_fei_tiff.py::test_fei_file_reading
tests/test_freeimage.py::test_gamma_correction
tests/test_freeimage.py::test_gamma_correction
  /tmp/imageio/.venv/lib/python3.11/site-packages/numpy/_core/_methods.py:127: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    ret = umr_sum(arr, axis, dtype, out, keepdims, where=where)

tests/test_ffmpeg.py: 11 warnings
tests/test_swf.py: 10 warnings
  /tmp/imageio/.venv/lib/python3.11/site-packages/numpy/_core/_methods.py:52: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    return umr_sum(a, axis, dtype, out, keepdims, initial, where)

tests/test_ffmpeg.py::test_read_and_write
tests/test_ffmpeg.py::test_read_and_write
  /tmp/imageio/tests/test_ffmpeg.py:151: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im11 == im21).all() and (im11 == im31).all()

tests/test_ffmpeg.py::test_read_and_write
tests/test_ffmpeg.py::test_read_and_write
  /tmp/imageio/tests/test_ffmpeg.py:152: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im12 == im22).all() and (im12 == im32).all()

tests/test_ffmpeg.py::test_read_and_write
tests/test_ffmpeg.py::test_read_and_write
  /tmp/imageio/tests/test_ffmpeg.py:153: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im13 == im23).all() and (im13 == im33).all()

tests/test_ffmpeg.py::test_read_and_write
  /tmp/imageio/tests/test_ffmpeg.py:155: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert not (im11 == im12).all()

tests/test_ffmpeg.py::test_read_and_write
  /tmp/imageio/tests/test_ffmpeg.py:156: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert not (im11 == im13).all()

tests/test_ffmpeg.py: 10 warnings
  /tmp/imageio/tests/test_ffmpeg.py:171: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    diff = np.abs(im1.astype(np.float32) - im2.astype(np.float32))

tests/test_ffmpeg.py: 10 warnings
  /tmp/imageio/tests/test_ffmpeg.py:215: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    diff = np.abs(im1[:, ::2].astype(np.float32) - im2.astype(np.float32))

tests/test_ffmpeg.py::test_reader_more
  /tmp/imageio/tests/test_ffmpeg.py:324: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im2).all()

tests/test_ffmpeg.py::test_reader_more
  /tmp/imageio/tests/test_ffmpeg.py:325: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im3).all()

tests/test_ffmpeg.py::test_reader_more
  /tmp/imageio/tests/test_ffmpeg.py:326: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert not (im1 == im4).all()

tests/test_freeimage.py: 181 warnings
  /tmp/imageio/tests/test_freeimage.py:135: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    diff = im1.astype("float32") - im2.astype("float32")

tests/test_freeimage.py: 18 warnings
  /tmp/imageio/imageio/plugins/freeimagemulti.py:310: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    x0, x1 = int(X[0]), int(X[-1]) + 1

tests/test_freeimage.py: 18 warnings
  /tmp/imageio/imageio/plugins/freeimagemulti.py:311: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    y0, y1 = int(Y[0]), int(Y[-1]) + 1

tests/test_freeimage.py::test_multi_icon_ico
  /tmp/imageio/tests/test_freeimage.py:617: DeprecationWarning: `row_stack` alias is deprecated. Use `np.vstack` directly.
    ims = im, np.column_stack((im, im)), np.row_stack((im, im))  # error on win

tests/test_freeimage.py::test_gamma_correction
  /tmp/imageio/tests/test_freeimage.py:670: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert np.all(im1 == im2)

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:43: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im == im2).all()

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:50: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im == im2).all()

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:57: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im == im3).all()

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:72: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (ims[0] == im2).all()

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:73: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (ims[1] == im3).all()

tests/test_npz.py::test_npz_reading_writing
  /tmp/imageio/tests/test_npz.py:74: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (ims[2] == im4).all()

tests/test_spe.py::test_metadata
  /tmp/imageio/imageio/plugins/spe.py:916: UserWarning: Failed to decode "sw_version" metadata string. Check `char_encoding` parameter.
    warnings.warn(

tests/test_spe.py::test_metadata
  /tmp/imageio/imageio/plugins/spe.py:344: UserWarning: Failed to decode SDT-control metadata field `sequence_type`: 'INVA'
    warnings.warn(

tests/test_spe.py::test_metadata
  /tmp/imageio/imageio/plugins/spe.py:425: UserWarning: Failed to decode SDT-control laser modulation script. Bad char_encoding?
    warnings.warn(

tests/test_swf.py::test_reading_saving
  /tmp/imageio/tests/test_swf.py:48: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (R.get_data(3) == ims1[3]).all()

tests/test_swf.py::test_reading_saving
  /tmp/imageio/tests/test_swf.py:59: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (R.get_data(10) == ims1[0]).all()

tests/test_swf.py: 10 warnings
  /tmp/imageio/tests/test_swf.py:82: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im2).all()

tests/test_swf.py: 10 warnings
  /tmp/imageio/tests/test_swf.py:89: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im3).all()

tests/test_swf.py: 10 warnings
  /tmp/imageio/tests/test_swf.py:97: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im4).all()

tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:66: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im == im2).all()

tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:74: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im == im2).all()  # note: this does not imply that the shape match!

tests/test_tifffile.py::test_tifffile_reading_writing
tests/test_tifffile.py::test_tifffile_reading_writing
tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:78: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (ims[i] == im2).all()

tests/test_tifffile.py::test_tifffile_reading_writing
tests/test_tifffile.py::test_tifffile_reading_writing
tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:87: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (vol[i] == im2).all()

tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:106: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (ims[0] == im2).all()

tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:123: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im3).all()

tests/test_tifffile.py::test_tifffile_reading_writing
  /tmp/imageio/tests/test_tifffile.py:132: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    assert (im1 == im3).all()

tests/test_tifffile.py::test_stk_volume
tests/test_tifffile.py::test_stk_volume
tests/test_tifffile.py::test_bool_writing
tests/test_v2.py::test_reader
tests/test_v2.py::test_reader
  /tmp/imageio/.venv/lib/python3.11/site-packages/numpy/_core/numeric.py:2411: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    result = (less_equal(abs(x-y), atol + rtol * abs(y))

tests/test_tifffile.py::test_stk_volume
tests/test_v2.py::test_reader
  /tmp/imageio/.venv/lib/python3.11/site-packages/numpy/_core/numeric.py:2412: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    & isfinite(y)

tests/test_tifffile.py::test_stk_volume
tests/test_tifffile.py::test_bool_writing
tests/test_v2.py::test_reader
  /tmp/imageio/.venv/lib/python3.11/site-packages/numpy/_core/numeric.py:2413: DeprecationWarning: __array_wrap__ must accept context and return_scalar arguments (positionally) in the future. (Deprecated NumPy 2.0)
    | (x == y))

tests/test_tifffile_v3.py::test_planarconfig
  /tmp/imageio/imageio/plugins/tifffile_v3.py:224: DeprecationWarning: <tifffile.TiffWriter.write> data with shape (3, 10, 10) and dtype 'uint8' are stored as RGB with separate component planes. Future versions will store such data as MINISBLACK in separate pages by default, unless the 'photometric' and 'planarconfig' parameters are specified.
    self._fh.write(image, **kwargs)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info =======================================================
FAILED tests/test_core.py::test_util_image - AssertionError: assert False
FAILED tests/test_dicom.py::test_selection - OverflowError: Python integer -1024 out of bounds for uint16
FAILED tests/test_dicom.py::test_v3_reading - OverflowError: Python integer -1024 out of bounds for uint16
============================ 3 failed, 307 passed, 5 skipped, 6 xfailed, 362 warnings in 110.89s (0:01:50) ============================
@Pandede
Copy link
Contributor

Pandede commented Apr 23, 2024

numpy v1 and v2 is incompatible, there is many breaking changes in API usage and namespace, that's why the tests broke.

@seberg
Copy link

seberg commented May 8, 2024

Looking at project that are working on supporing NumPy 2. My suspicion is that the easiest fix will be to do a change such as changing:

minReq, maxReq = data.min(), data.max()

to

minReq, maxReq = data.min().item(), data.max().item()

or call int() since I think you know that you have integers in this path. That should end up with the same thing (and is also probably slightly faster).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants