Skip to content

Support numpy 1.24.x, make tests pass with latest dependencies#2767

Open
rly wants to merge 22 commits intoAllenInstitute:masterfrom
rly:feature/update-requirements
Open

Support numpy 1.24.x, make tests pass with latest dependencies#2767
rly wants to merge 22 commits intoAllenInstitute:masterfrom
rly:feature/update-requirements

Conversation

@rly
Copy link

@rly rly commented Jan 11, 2026

Overview:

My main goal was to update the numpy dependency from <1.24 to <1.25 to address compatibility issues with other packages in my environment -- primarily pynwb and hdmf for which the latest versions require numpy>=1.24. However, running the test suite with the latest dependencies, regardless of the numpy change, presented several errors and deprecations. Those are addressed in this PR as well. I am happy to break up this PR into smaller ones if that is preferred, but most of the tests will not pass unless all of these changes (except the numpy change) are merged. I believe the tests that are failing are not due to changes in this PR. The linting issues derive from other parts of the code base -- I think the linter has become more strict.

Addresses:

Type of Fix:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
  • Documentation Change

Solution:

Changes:

  • Update numpy version constraint to allow 1.24.x from <1.24
  • Fix pytest 9 deprecation warnings
  • Update moto to v5+ and fix mock_s3 to mock_aws imports
  • Remove redundant decorator
  • Fix pynwb compatibility issues
  • Fix pytest.warns(None) TypeError in newer pytest versions
  • Fix GitHub Actions for macos-latest ARM64 transition and update some GitHub Actions versions (this could be done more thoroughly)
  • Fix aiohttp ClientSession creation outside async context
  • Fix numpy 1.24+ inhomogeneous array in gaze_mapper
  • Fix test_fitgaussian2D_failure mock for numpy 1.24+ compatibility
  • Drop Python 3.8/3.9 support and handle missing glymur gracefully
  • Added tolerance for curve fitting tests on ARM64

This was done with the help of Claude Code.

Validation:

Screenshots:

Unit Tests:

Script to reproduce error and fix:

Configuration details:

Checklist

  • My code follows
    Allen Institute Contribution Guidelines
  • My code is unit tested and does not decrease test coverage
  • I have performed a self review of my own code
  • My code is well-documented, and the docstrings conform to
    Numpy Standards
  • I have updated the documentation of the repository where
    appropriate
  • The header on my commit includes the issue number
  • My Pull Request has the latest AllenSDK release candidate branch
    rc/x.y.z as its merge target
  • My code passes all AllenSDK tests

Notes:

rly and others added 20 commits November 21, 2025 13:27
- Update numpy<1.24 to numpy<1.25 in requirements.txt and doc_requirements.txt
- Fix numpy 1.24+ compatibility issue in test conftest.py where
  rng.choice() no longer accepts sequences with inhomogeneous shapes
  (lists of different lengths). Use rng.integers() to generate indices instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update numpy version constraint to allow 1.24.x
- Update pytest_ignore_collect hooks to use collection_path parameter
  instead of deprecated path parameter (py.path.local -> pathlib.Path)
- Remove pytest.mark decorators from fixtures (marks on fixtures have
  no effect in pytest 9+)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update moto from 3.0.7 to >=5.0.0 in test_requirements.txt
- Replace deprecated `from moto import mock_s3` with `from moto import mock_aws`
- Replace all `@mock_s3` decorators with `@mock_aws`

This fixes JSONDecodeError issues caused by moto 3.x incompatibility with
newer botocore versions returning chunked transfer encoding data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update moto to v5+ and fix mock_s3 to mock_aws imports
- Replace deprecated nwbfile.modules with nwbfile.processing
- Fix IndexSeries unit from 'None' to 'N/A' (required in newer pynwb)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace deprecated nwbfile.modules with nwbfile.processing
- Fix IndexSeries unit from 'None' to 'N/A' (required in newer pynwb)
- Deprecate _add_image_index_to_nwb method (11/2025): IndexSeries
  indexed_timeseries field is deprecated in pynwb 2.x
- Add warning when to_nwb() would have previously added IndexSeries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace pytest.warns(None) with warnings.catch_warnings(record=True)
to capture warnings in newer pytest versions where pytest.warns(None)
raises TypeError. Also rename local 'warnings' variables from
pytest.warns() contexts to avoid shadowing the warnings module.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change macos-latest to macos-13 for x86_64 architecture since
  macos-latest now refers to ARM64 (Apple Silicon) runners which
  have conda package compatibility issues
- Update setup-miniconda from v2 to v3 for better compatibility
- Update actions/checkout from v2/v3 to v4 across all workflows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
In aiohttp 3.9+, ClientSession must be created within a running event
loop. Changed AsyncHttpEngine to lazily create the session on first
access rather than in __init__, fixing "RuntimeError: no running event
loop" errors when instantiating AsyncHttpEngine outside async context.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
In pupil_position_on_monitor_in_degrees(), np.linalg.norm([x, mag])
created an inhomogeneous array where x is an array and mag is a scalar.
Use np.vstack with np.full_like to create a proper 2D homogeneous array.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The test was not mocking res.x, causing MagicMock objects to be mixed
with numpy scalars when creating arrays, which fails in numpy 1.24+
due to inhomogeneous array restrictions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update python_requires to >=3.10 in setup.py
- Update classifiers to list Python 3.10, 3.11, 3.12
- Update CI workflows to test only Python 3.10, 3.11, 3.12
- Update on-prem docker images from py38 to py310
- Handle missing jpeg_twok/glymur by deferring ImportError to use time
- Remove Python 2 compatibility code (six.iteritems, __future__ division)

Python 3.8 reached EOL in October 2024 and Python 3.9 is in its final
security-only maintenance phase. Dropping these versions allows us to
use modern glymur which requires Python 3.10+ syntax (match-case).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
numpy 1.24.x doesn't support Python 3.12+ due to removed pkgutil.ImpImporter.
Restrict to Python 3.10-3.11 until numpy version constraints are relaxed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Drop Python 3.8/3.9 support and handle missing jpeg_twok/glymur gracefully
@CLAassistant
Copy link

CLAassistant commented Jan 11, 2026

CLA assistant check
All committers have signed the CLA.

rly and others added 2 commits January 10, 2026 21:27
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
scipy.optimize.curve_fit can converge to different solutions on ARM64
vs x86_64 due to floating point differences. Added rtol/atol tolerance
to affected tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

2 participants