GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix for NumPy 1.25 by jarrodmillman · Pull Request #6970 · scikit-image/scikit-image

Conversation

@jarrodmillman

@jarrodmillman jarrodmillman commented May 31, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Follow-up to #6969 and #6973. This re-enables the tests for NumPy 1.25 we still need to sort out what to do about the 7 failing tests

===== 7 failed, 8369 passed, 20 skipped, 10 warnings in 356.97s (0:05:56) ======

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jarrodmillman jarrodmillman added the 🔧 type: Maintenance Refactoring and maintenance of internals label May 31, 2023
@jarrodmillman jarrodmillman assigned stefanv May 31, 2023
@stefanv

stefanv commented May 31, 2023 •
edited by jarrodmillman
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Most of the failures are related to changes in NumPy's cos/sin implementation. These changes widely affect other packages in the ecosystem as well, so I presume it will be discussed on tomorrow's triage meeting @seberg?

If we are guaranteed that the new implementation is more accurate than the previous one across the board, then I'd be okay fixing all those tests. But if it varies from place to place, the change may warrant further discussion?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented May 31, 2023

Copy link
Copy Markdown
Contributor

For reference we already dealt with this in Matplotlib : matplotlib/matplotlib#25813 and matplotlib/matplotlib#25789 .

jarrodmillman reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from d1873bc to 7924a0c Compare June 1, 2023 22:07
@jni

jni commented Jun 2, 2023

Copy link
Copy Markdown
Member

fwiw I do think the change in NumPy should be reverted (agree with all the comments in the mailing list thread arguing for that, including the point about teaching), but at the same time, maybe we should also fix our tests to not depend on exact matches for those special values...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stefanv

stefanv commented Jun 2, 2023

Copy link
Copy Markdown
Member

@jni The way many of these tests were constructed is to take an image, transform it with some parameters (which affect the output shape), and to confirm that it's correct. Then, that gets enshrined in the test suite. Now, it's still correct, but the shapes are slightly off :/ And it's strange to test for shape +- 1 on all dimensions, that's a bit rough. So, how do we do it? Perhaps choose better angles for the transforms?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

Do you see any flakyness of these same tests across architectures / platforms?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stefanv

stefanv commented Jun 2, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I think our CI is limited that way (chip instruction sets), but at least across numpy versions during the transition we'll have problems.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

For Matplotlib we occasionally get reports from the Debian packager of test failures on exotic architectures / endianess / bit size systems (most of them are RBGA values changing by +/-1 presumably due to float rounding issues), I was wondering if skimage got the same and if these tests were the ones that also had issues there. If that were the case it might be extra motivation to make these tests less brittle.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jni

jni commented Jun 3, 2023

Copy link
Copy Markdown
Member

@stefanv

And it's strange to test for shape +- 1 on all dimensions, that's a bit rough. So, how do we do it? Perhaps choose better angles for the transforms?

np.testing.assert_allclose(shape_actual, shape_ref, atol=1.5)?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jarrodmillman added a commit to jarrodmillman/scikit-image that referenced this pull request Jun 4, 2023
@jarrodmillman
Don't test numpy prerelease on azure
50f4a46
Will fix in scikit-image#6970
@jarrodmillman jarrodmillman mentioned this pull request Jun 4, 2023
Don't test numpy prerelease on azure #6996
Merged
stefanv pushed a commit that referenced this pull request Jun 5, 2023
@jarrodmillman
Don't test numpy prerelease on azure (#6996)
e57c23d
Will fix in #6970
@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from 7924a0c to 78096f2 Compare June 26, 2023 14:19
@jni

jni commented Jun 27, 2023

Copy link
Copy Markdown
Member

Can we just close this now that NumPy reverted those changes? Or do we want to keep this as an improvement?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lagru

lagru commented Jun 27, 2023

Copy link
Copy Markdown
Member

I think this needs to be merged to remove the skip of NumPy 1.25 on Azure?

jni reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from 3af93fa to 3d55001 Compare June 28, 2023 02:32
@jarrodmillman
jarrodmillman marked this pull request as draft June 28, 2023 02:34
@jarrodmillman

jarrodmillman commented Jun 28, 2023

Copy link
Copy Markdown
Contributor Author

We still need to sort out what to do about the 7 failing tests

===== 7 failed, 8369 passed, 20 skipped, 10 warnings in 356.97s (0:05:56) ======
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman

jarrodmillman commented Jun 28, 2023

Copy link
Copy Markdown
Contributor Author

I just noticed linux-cp3.11-pre has

===== 10 failed, 8366 passed, 20 skipped, 2 warnings in 338.15s (0:05:38) ======
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from 1d2fe13 to c4d9ead Compare June 30, 2023 21:56
@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch 2 times, most recently from 8a41854 to 63fcbf6 Compare July 9, 2023 00:04
@jarrodmillman jarrodmillman mentioned this pull request Jul 9, 2023
Nightly builds are failing #7042
Closed
@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from e747c1b to 5a46c64 Compare July 9, 2023 14:54
@stefanv

stefanv commented Aug 1, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
 skimage/morphology/tests/test_util.py::test_offsets_to_raveled_neighbors_explicit_0
 skimage/feature/tests/test_corner.py::test_subpix_border
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jarrodmillman added 3 commits August 1, 2023 10:50
@jarrodmillman
Fix for NumPy 1.25
5e8393d
@jarrodmillman
Revert scikit-image#6973
2fcd980
@jarrodmillman
Revert "Don't test numpy prerelease on azure (scikit-image#6996)"
d6871dd
This reverts commit e57c23d.
@lagru

lagru commented Aug 5, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Enabling stable sorting in _raveled_offsets_and_distances seemed to do the trick for test_offsets_to_raveled_neighbors_explicit_*. I think we can justify the changed ordering and output with the reasoning that from now on it should be guaranteed to be stable.

jarrodmillman reacted with thumbs up emoji stefanv reacted with hooray emoji stefanv reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jarrodmillman and others added 7 commits August 14, 2023 04:17
@jarrodmillman
Fix for NumPy 1.25
03c8f07
@jarrodmillman
Revert scikit-image#6973
d94ee22
@jarrodmillman
Revert "Don't test numpy prerelease on azure (scikit-image#6996)"
b3fefb1
This reverts commit e57c23d.
@stefanv @jarrodmillman
Skip warning check on older, noisier versions of NumPy
38c3ca7
@jarrodmillman
Remove upperpin
10d27f1
@lagru @jarrodmillman
Use stable sort in _raveled_offsets_and_distances
6f9e7b9
NumPy enabled optimizations for quicksort on AVX-512 enabled
processors [1]. We sort based on neighbor distances which can be equal.
The default quicksort is not stable and could have different behavior on
AVX-512. Test this assumption.

[1] https://numpy.org/devdocs/release/1.25.0-notes.html#faster-np-argsort-on-avx-512-enabled-processors
@lagru @jarrodmillman
Fix forgotten doctest in _offsets_to_raveled_neighbors
c350740
after updating to stable sort internally.
@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from 729c8de to c350740 Compare August 14, 2023 11:18
@jarrodmillman
Handle rank>0 scalar arrays
20b9a56
numpy/numpy#10404
@jarrodmillman
jarrodmillman force-pushed the numpy-1.25 branch from 266a801 to 20b9a56 Compare August 14, 2023 12:22
jarrodmillman and others added 3 commits August 14, 2023 05:54
@jarrodmillman
Use stable sort
0d936f4
@lagru
Merge remote-tracking branch 'jarrodmillman/numpy-1.25' into pr6970-n…
9c72b25
…umpy-1.25

# Conflicts:
#	skimage/morphology/_util.py
@lagru
Use stable sort in max_tree (debug)
022d696
See if it does anything.
lagru
lagru reviewed Aug 15, 2023
View reviewed changes
Comment thread skimage/morphology/_util.py
Comment on lines 158 to +160
_, indices = np.unique(sorted_raveled_offsets, return_index=True)
sorted_raveled_offsets = sorted_raveled_offsets[np.sort(indices)]
sorted_distances = sorted_distances[np.sort(indices)]
indices = np.sort(indices, kind="stable")
sorted_raveled_offsets = sorted_raveled_offsets[indices]

@lagru lagru Aug 15, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indices contains only unique values, so "quicksort" and "stable" should have the same behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jarrodmillman reacted with thumbs up emoji seberg reacted with hooray emoji seberg reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
  • 🚀 1 reaction

@stefanv stefanv Aug 17, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These sorts probably don't differ by much, but why specify stable here if it's not necessary?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lagru
Use stable sort in _get_high_intensity_peaks (debug)
8a59eda
See if it does anything.
@lagru

lagru commented Aug 15, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Okay fixed the two remaining failing test by switching to stable sorting at the appropriate place. Going forward, we should probably consider stable sorting as the default and use quicksort only if there is enough to warrant the trade-off of unstable sorting.

Details
Subject: [PATCH] Use stable sort everywhere
---
Index: skimage/util/_regular_grid.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/util/_regular_grid.py b/skimage/util/_regular_grid.py
--- a/skimage/util/_regular_grid.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/util/_regular_grid.py	(date 1692119211772)
@@ -60,7 +60,7 @@
     """
     ar_shape = np.asanyarray(ar_shape)
     ndim = len(ar_shape)
-    unsort_dim_idxs = np.argsort(np.argsort(ar_shape))
+    unsort_dim_idxs = np.argsort(np.argsort(ar_shape, kind="stable"))
     sorted_dims = np.sort(ar_shape)
     space_size = float(np.prod(ar_shape))
     if space_size <= n_points:
Index: skimage/transform/tests/test_hough_transform.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/transform/tests/test_hough_transform.py b/skimage/transform/tests/test_hough_transform.py
--- a/skimage/transform/tests/test_hough_transform.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/transform/tests/test_hough_transform.py	(date 1692119211772)
@@ -260,7 +260,7 @@
                                        min_ydistance=1, threshold=None,
                                        num_peaks=np.inf,
                                        total_num_peaks=np.inf)
-    s = np.argsort(out[3])  # sort by radii
+    s = np.argsort(out[3], kind="stable")  # sort by radii
     assert_equal(out[1][s], np.array([y_0, y_1]))
     assert_equal(out[2][s], np.array([x_0, x_1]))
     assert_equal(out[3][s], np.array([rad_0, rad_1]))
Index: skimage/transform/hough_transform.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/transform/hough_transform.py b/skimage/transform/hough_transform.py
--- a/skimage/transform/hough_transform.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/transform/hough_transform.py	(date 1692119211772)
@@ -354,9 +354,9 @@
     cy = np.array(cy)
     accum = np.array(accum)
     if normalize:
-        s = np.argsort(accum / r)
+        s = np.argsort(accum / r, kind="stable")
     else:
-        s = np.argsort(accum)
+        s = np.argsort(accum, kind="stable")
     accum_sorted, cx_sorted, cy_sorted, r_sorted = \
         accum[s][::-1], cx[s][::-1], cy[s][::-1], r[s][::-1]
 
Index: skimage/feature/peak.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py
--- a/skimage/feature/peak.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/feature/peak.py	(date 1692119211772)
@@ -404,7 +404,7 @@
     xcoords_peaks = np.array(xcoords_peaks)
 
     if num_peaks < len(img_peaks):
-        idx_maxsort = np.argsort(img_peaks)[::-1][:num_peaks]
+        idx_maxsort = np.argsort(img_peaks, kind="stable")[::-1][:num_peaks]
         img_peaks = img_peaks[idx_maxsort]
         ycoords_peaks = ycoords_peaks[idx_maxsort]
         xcoords_peaks = xcoords_peaks[idx_maxsort]
Index: skimage/transform/radon_transform.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/transform/radon_transform.py b/skimage/transform/radon_transform.py
--- a/skimage/transform/radon_transform.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/transform/radon_transform.py	(date 1692119211772)
@@ -338,7 +338,7 @@
     """
     interval = 180
 
-    remaining_indices = list(np.argsort(theta))   # indices into theta
+    remaining_indices = list(np.argsort(theta, kind="stable"))   # indices into theta
     # yield an arbitrary angle to start things off
     angle = theta[remaining_indices[0]]
     yield remaining_indices.pop(0)
Index: skimage/morphology/grayreconstruct.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/skimage/morphology/grayreconstruct.py b/skimage/morphology/grayreconstruct.py
--- a/skimage/morphology/grayreconstruct.py	(revision 8a59eda7bb4609636ba8e0c9ecfa122f0b4bad7c)
+++ b/skimage/morphology/grayreconstruct.py	(date 1692119211772)
@@ -179,7 +179,8 @@
     images = images.reshape(-1)
 
     # Erosion goes smallest to largest; dilation goes largest to smallest.
-    index_sorted = np.argsort(images).astype(signed_int_dtype, copy=False)
+    index_sorted = np.argsort(images, kind="stable")
+    index_sorted = index_sorted.astype(signed_int_dtype, copy=False)
     if method == 'dilation':
         index_sorted = index_sorted[::-1]
 

Though, now we get a memory corruption or something like that on pre. It looks reproducable. 🤔 windows job with more details

jarrodmillman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stefanv

stefanv commented Aug 15, 2023

Copy link
Copy Markdown
Member

Well done figuring out the problem!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lagru

lagru commented Aug 16, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Okay, after some digging I am still clueless:

  • The core dump / memfault seems to happen in https://github.com/numpy/numpy/blob/v1.26.0b1/numpy/linalg/linalg.py#L1181
  • I can reproduce locally if I install Numpy v1.26.0b1 and run test_multiscale_basic_features_channel_axis.
    • But if I use PyCharms debugger, I get different errors.
Details
FAILED [ 20%]
test_basic_features.py:39 (test_multiscale_basic_features_channel_axis[0])
channel_axis = 0

    @pytest.mark.parametrize('channel_axis', [0, 1, 2, -1, -2])
    def test_multiscale_basic_features_channel_axis(channel_axis):
        num_channels = 5
        shape_spatial = (10, 10)
        ndim = len(shape_spatial)
        shape = tuple(
            np.insert(shape_spatial, channel_axis % (ndim + 1), num_channels)
        )
        img = np.zeros(shape)
        img[:10] = 1
        img += 0.05 * np.random.randn(*img.shape)
        n_sigmas = 2
    
        # features for all channels are concatenated along the last axis
        features = multiscale_basic_features(img, sigma_min=1, sigma_max=2,
                                             channel_axis=channel_axis)
        assert features.shape[-1] == 5 * n_sigmas * 4
        assert features.shape[:-1] == np.moveaxis(img, channel_axis, -1).shape[:-1]
    
        # Consider channel_axis as spatial dimension
>       features = multiscale_basic_features(img, sigma_min=1, sigma_max=2)

test_basic_features.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../_basic_features.py:180: in multiscale_basic_features
    features = list(itertools.chain.from_iterable(all_results))
../_basic_features.py:168: in <genexpr>
    _mutiscale_basic_features_singlechannel(
../_basic_features.py:87: in _mutiscale_basic_features_singlechannel
    out_sigmas = list(
/usr/lib/python3.11/concurrent/futures/_base.py:619: in result_iterator
    yield _result_or_cancel(fs.pop())
/usr/lib/python3.11/concurrent/futures/_base.py:317: in _result_or_cancel
    return fut.result(timeout)
/usr/lib/python3.11/concurrent/futures/_base.py:449: in result
    return self.__get_result()
/usr/lib/python3.11/concurrent/futures/_base.py:401: in __get_result
    raise self._exception
/usr/lib/python3.11/concurrent/futures/thread.py:58: in run
    result = self.fn(*self.args, **self.kwargs)
../_basic_features.py:89: in <lambda>
    lambda s: _singlescale_basic_features_singlechannel(
../_basic_features.py:28: in _singlescale_basic_features_singlechannel
    results += (*_texture_filter(gaussian_filtered),)
../_basic_features.py:14: in _texture_filter
    eigvals = feature.hessian_matrix_eigvals(H_elems)
../corner.py:510: in hessian_matrix_eigvals
    return _symmetric_compute_eigenvalues(H_elems)
../corner.py:412: in _symmetric_compute_eigenvalues
    eigs = np.linalg.eigvalsh(matrices)[..., ::-1]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = array([[[[[-1.76429749e-05, -3.95774841e-05, -8.44955444e-04],
          [-3.95774841e-05, -6.33984804e-04,  1.6325712...00112772e-04,  2.67672539e-03],
          [ 9.18269157e-04,  2.67672539e-03,  0.00000000e+00]]]]],
      dtype=float32)
UPLO = 'L'

    @array_function_dispatch(_eigvalsh_dispatcher)
    def eigvalsh(a, UPLO='L'):
        """
        Compute the eigenvalues of a complex Hermitian or real symmetric matrix.
    
        Main difference from eigh: the eigenvectors are not computed.
    
        Parameters
        ----------
        a : (..., M, M) array_like
            A complex- or real-valued matrix whose eigenvalues are to be
            computed.
        UPLO : {'L', 'U'}, optional
            Specifies whether the calculation is done with the lower triangular
            part of `a` ('L', default) or the upper triangular part ('U').
            Irrespective of this value only the real parts of the diagonal will
            be considered in the computation to preserve the notion of a Hermitian
            matrix. It therefore follows that the imaginary part of the diagonal
            will always be treated as zero.
    
        Returns
        -------
        w : (..., M,) ndarray
            The eigenvalues in ascending order, each repeated according to
            its multiplicity.
    
        Raises
        ------
        LinAlgError
            If the eigenvalue computation does not converge.
    
        See Also
        --------
        eigh : eigenvalues and eigenvectors of real symmetric or complex Hermitian
               (conjugate symmetric) arrays.
        eigvals : eigenvalues of general real or complex arrays.
        eig : eigenvalues and right eigenvectors of general real or complex
              arrays.
        scipy.linalg.eigvalsh : Similar function in SciPy.
    
        Notes
        -----
    
        .. versionadded:: 1.8.0
    
        Broadcasting rules apply, see the `numpy.linalg` documentation for
        details.
    
        The eigenvalues are computed using LAPACK routines ``_syevd``, ``_heevd``.
    
        Examples
        --------
        >>> from numpy import linalg as LA
        >>> a = np.array([[1, -2j], [2j, 5]])
        >>> LA.eigvalsh(a)
        array([ 0.17157288,  5.82842712]) # may vary
    
        >>> # demonstrate the treatment of the imaginary part of the diagonal
        >>> a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]])
        >>> a
        array([[5.+2.j, 9.-2.j],
               [0.+2.j, 2.-1.j]])
        >>> # with UPLO='L' this is numerically equivalent to using LA.eigvals()
        >>> # with:
        >>> b = np.array([[5.+0.j, 0.-2.j], [0.+2.j, 2.-0.j]])
        >>> b
        array([[5.+0.j, 0.-2.j],
               [0.+2.j, 2.+0.j]])
        >>> wa = LA.eigvalsh(a)
        >>> wb = LA.eigvals(b)
        >>> wa; wb
        array([1., 6.])
        array([6.+0.j, 1.+0.j])
    
        """
        UPLO = UPLO.upper()
        if UPLO not in ('L', 'U'):
            raise ValueError("UPLO argument must be 'L' or 'U'")
    
        extobj = get_linalg_error_extobj(
            _raise_linalgerror_eigenvalues_nonconvergence)
        if UPLO == 'L':
            gufunc = _umath_linalg.eigvalsh_lo
        else:
            gufunc = _umath_linalg.eigvalsh_up
    
        a, wrap = _makearray(a)
        _assert_stacked_2d(a)
        _assert_stacked_square(a)
        t, result_t = _commonType(a)
        signature = 'D->d' if isComplexType(t) else 'd->d'
>       w = gufunc(a, signature=signature, extobj=extobj)
E       ValueError: On entry to DSYEVD parameter number 8 had an illegal value

/home/lg/.local/lib/venv/skimagedev/lib/python3.11/site-packages/numpy/linalg/linalg.py:1181: ValueError

I'll open an issue in NumPy and ask nicely for support., not sure yet if this is our fault..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lagru

lagru commented Aug 16, 2023

Copy link
Copy Markdown
Member

For local debugging with NumPy v1.26.0b1

import numpy as np
from skimage.feature import multiscale_basic_features

channel_axis = 0
num_channels = 5
shape_spatial = (10, 10)
ndim = len(shape_spatial)
shape = tuple(
    np.insert(shape_spatial, channel_axis % (ndim + 1), num_channels)
)
img = np.zeros(shape)
img[:10] = 1
img += 0.05 * np.random.randn(*img.shape)

features = multiscale_basic_features(img, sigma_min=1, sigma_max=2)

Is it possible that np.linalg.eigenvals no longer supports multi-threading somehow? If I set the number of workers in

scikit-image/skimage/feature/_basic_features.py

Line 86 in 161ee8b

with ThreadPoolExecutor(max_workers=num_workers) as ex:

to 1, the error disappears...

jarrodmillman reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman
Upper pin numpy<1.26 for tests
a5f328f
@jarrodmillman
jarrodmillman marked this pull request as ready for review August 17, 2023 01:55
@jarrodmillman

jarrodmillman commented Aug 17, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@stefanv @lagru This PR was started with the goal of supporting NumPy 1.25, so I just upperpinned numpy<1.26 in a5f328f. Let's merge this and and open a new PR undoing a5f328f and add @lagru comments above about numpy 1.26.

lagru reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jarrodmillman
jarrodmillman enabled auto-merge (squash) August 17, 2023 02:15
@jarrodmillman
jarrodmillman requested a review from stefanv August 17, 2023 04:28
stefanv
stefanv approved these changes Aug 17, 2023
View reviewed changes
@jarrodmillman
jarrodmillman merged commit 01a9282 into scikit-image:main Aug 17, 2023
@stefanv stefanv added this to the 0.22 milestone Aug 17, 2023
@jarrodmillman jarrodmillman mentioned this pull request Aug 18, 2023
Fix for NumPy 1.26 #7101
Merged
@lagru lagru mentioned this pull request Aug 23, 2023
BUG: SIGABRT on using ThreadPoolExecutor with linalg.eigvalsh in v1.26.0b1 numpy/numpy#24512
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lagru lagru lagru left review comments
@stefanv stefanv stefanv approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@stefanv stefanv

Labels

🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Milestone

0.22

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@jarrodmillman @stefanv @tacaswell @jni @lagru
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.