Skip to content

Remove NumPy < 2.2 version pin for Python 3.14 once upstream bug is fixed #34

@trissim

Description

@trissim

Issue

We currently pin NumPy to < 2.2 for Python 3.14 due to a compatibility bug in NumPy 2.2.x that causes ValueError: operands could not be broadcast together with shapes in scikit-image's histogram/bincount functions.

Error Details

ValueError: operands could not be broadcast together with shapes (256,) (258,) (256,)
  File "skimage/filters/thresholding.py", line 390, in threshold_otsu
    counts, bin_centers = _validate_image_histogram(image, hist, nbins)
  File "skimage/exposure/exposure.py", line 274, in histogram
    hist, bin_centers = _histogram(image, nbins, source_range, normalize)
  File "numpy/lib/_histograms_impl.py", line 876, in histogram
    n += np.bincount(indices, weights=tmp_w, minlength=n_equal_bins).astype(ntype)

Current Workaround

In pyproject.toml:

"numpy>=1.26.4,<2.2; python_version>='3.14'",
"numpy>=1.26.4; python_version<'3.14'",

Action Items

  • Monitor NumPy releases for fix (check NumPy 2.2.1+)
  • Monitor scikit-image releases for workaround
  • Test with newer NumPy versions when available
  • Remove version constraint once bug is fixed
  • Update CI to test with latest NumPy

References

How to Test

Once a fix is available:

# Remove the version pin from pyproject.toml
# Then test:
python3.14 -m pytest tests/integration/test_main.py \
  --it-backends disk \
  --it-microscopes ImageXpress \
  -v

If tests pass, the pin can be removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions