Skip to content

chore: Migrate to numpy 2.x, pydantic 2.13, and target Python 3.12-3.14#143

Open
tlambert03 wants to merge 13 commits into
mainfrom
numpy2-py312-modernization
Open

chore: Migrate to numpy 2.x, pydantic 2.13, and target Python 3.12-3.14#143
tlambert03 wants to merge 13 commits into
mainfrom
numpy2-py312-modernization

Conversation

@tlambert03

Copy link
Copy Markdown
Owner

numpy 2.x compatibility:

  • _simple_psf: cast 0-d xarray bounds to float before np.linspace (numpy>=2 array_wrap rewraps into a mismatched Variable)
  • fft/convolve: accept (and ignore) the xp arg scipy>=1.15 added to _apply_conv_mode
  • _data_array/simulation: coerce jax arrays to contiguous numpy before zarr write (numcodecs uses np.array(copy=False), strict on numpy>=2)
  • spectrum: np.trapz -> np.trapezoid (removed in numpy 2.0)
  • mypy-under-numpy-2 cleanups; ignore xarray's import-time timedelta warning

pydantic 2.13:

  • space: convert deprecated classmethod-style model_validator(mode="after") to an instance method

Python 3.12-3.14:

  • requires-python >=3.12; CI matrix -> 3.12/3.13/3.14; classifiers updated
  • drop dm-tree (replace its sole tree.map_structure use in vendored xarray_jax with a local helper, mirroring upstream)
  • per-python min pins for compiled deps (numpy/scipy/tensorstore/pydantic/ matplotlib) reflecting first cp31x wheels; pyopengl-accelerate gated <3.14
  • test_docs: give exec() a shared namespace (PEP 667 ended locals leak on 3.13)
  • skip matplotlib plotting on 3.14 (upstream ax.plot deepcopy recursion)

tlambert03 and others added 2 commits June 22, 2026 08:24
numpy 2.x compatibility:
- _simple_psf: cast 0-d xarray bounds to float before np.linspace
  (numpy>=2 __array_wrap__ rewraps into a mismatched Variable)
- fft/convolve: accept (and ignore) the `xp` arg scipy>=1.15 added to
  _apply_conv_mode
- _data_array/simulation: coerce jax arrays to contiguous numpy before
  zarr write (numcodecs uses np.array(copy=False), strict on numpy>=2)
- spectrum: np.trapz -> np.trapezoid (removed in numpy 2.0)
- mypy-under-numpy-2 cleanups; ignore xarray's import-time timedelta warning

pydantic 2.13:
- space: convert deprecated classmethod-style model_validator(mode="after")
  to an instance method

Python 3.12-3.14:
- requires-python >=3.12; CI matrix -> 3.12/3.13/3.14; classifiers updated
- drop dm-tree (replace its sole tree.map_structure use in vendored
  xarray_jax with a local helper, mirroring upstream)
- per-python min pins for compiled deps (numpy/scipy/tensorstore/pydantic/
  matplotlib) reflecting first cp31x wheels; pyopengl-accelerate gated <3.14
- test_docs: give exec() a shared namespace (PEP 667 ended locals leak on 3.13)
- skip matplotlib plotting on 3.14 (upstream ax.plot deepcopy recursion)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.66%. Comparing base (33e50b5) to head (96efeb4).

Files with missing lines Patch % Lines
src/microsim/schema/spectrum.py 50.00% 1 Missing ⚠️
src/microsim/util.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #143       +/-   ##
===========================================
+ Coverage   60.58%   83.66%   +23.07%     
===========================================
  Files          47       47               
  Lines        3032     3036        +4     
===========================================
+ Hits         1837     2540      +703     
+ Misses       1195      496      -699     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tlambert03 and others added 10 commits June 22, 2026 08:53
- Added a constraint for pillow to require version >=11.3.0 for Python 3.14 and above in pyproject.toml.
- Updated uv.lock to reflect the new pillow versioning, including separate entries for versions 11.2.1 and 12.2.0 based on Python version.
- Modified _client.py to handle HTTPError properly when fetching Supabase URL and key.
- uv.lock: full upgrade so transitive deps (pandas, etc.) move to versions
  shipping cp314 wheels (old pins source-built and failed on linux/windows 3.14)
- pyproject: ignore ResourceWarning / PytestUnraisableExceptionWarning — py3.14's
  GC surfaces unclosed sockets from third-party network clients (supabase/s3fs)
  as fatal warnings under filterwarnings=error
- tests/_util: close the internet-check socket (another leaked-socket source)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nned 0.45.3)

The full lock upgrade bumped griffe-fieldz to 0.5.0, which imports DocstringAttribute
from griffe (only in newer griffe), breaking the strict mkdocs build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
supabase>=2.31 passes now-deprecated timeout/verify/proxy params to its postgrest
client, which filterwarnings=error promoted to fatal errors in every COSEM test
(the query itself works fine outside pytest).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hypothesis: coverage's C tracer exits non-zero at interpreter teardown on
Windows with the bumped C-extensions (jax/torch/tensorstore), despite all
tests passing. sys.monitoring avoids the C tracer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The culprit was identified as tensorstore's S3/HTTP transport crashing at
interpreter shutdown on Windows (google/tensorstore#275), now handled by the
version pin + matrix exclude. The diagnostic backend-import step is no longer
needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml Outdated
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.

1 participant