Skip to content

Test against minimum dependencies, remove old deps#2301

Merged
VeckoTheGecko merged 20 commits intoParcels-code:v4-devfrom
andrew-s28:minimum-deps
Oct 8, 2025
Merged

Test against minimum dependencies, remove old deps#2301
VeckoTheGecko merged 20 commits intoParcels-code:v4-devfrom
andrew-s28:minimum-deps

Conversation

@andrew-s28
Copy link
Copy Markdown
Contributor

@andrew-s28 andrew-s28 commented Oct 4, 2025

Fixes #2286, fixes #2292, fixes #2304

Finding the minimum dependencies that pass the tests was a little bit tricky. It turns out that, since the dependencies aren't pinned for the Python 3.11 tests, anything below NumPy 2.3.3 isn't currently being tested.

When I tried to use NumPy 1.x (even the most recent 1.26.4), the tests fail with 109 errors. Most of these seem to be caused by changes in how NumPy handles casting array values, which I think changed with NumPy 2.x (but I couldn't find a super defnitive PR over in the NumPy repo). However, even at NumPy 2.0.x the tests fail with 4 errors, still caused by some minor casting issues. Finally, using NumPy 2.1.0, all the tests pass.

Pinning NumPy to 2.1.0 is above the minimum shown in SPEC0, and forces several other dependencies to have more recent minimum versions. Currently I have this as a draft PR to determine how best to handle this. For example, if these are the minimum versions that pass tests, should the minimums in the core dependencies section also be updated? Should the tests be modified?

Minimum reproducible examples are shown in the drop downs below. Environment details for test-py311 and test-minimum can be found in the attached files (or by running pixi list -e test-py311 and pixi list -e test-minimum).

test-minimum.txt
test-py311.txt

Minimum Reproducible Example
# test_dates.py

import numpy as np
from cftime import datetime as cftime_datetime

cf = cftime_datetime(1900, 1, 1, calendar="365_day")
td = np.timedelta64(86400, "s")

print(all(np.array([td]) >= 0))  # errors for NumPy<=1.26.4
print(cf + td)  # errors for NumPy>=2.0.0,<2.1.0

I used uv to run the test script, which was easier for quick demonstration purposes:

$ uv run --with 'numpy==1.26.4,cftime' test_dates.py
$ uv run --with 'numpy==2.0.2,cftime' test_dates.py

You should see them each fail on one of the two print lines.

Running Test Suite with Different NumPy Versions In order to reproduce the tests failing, you can replace all of the dependencies under the [feature.minimum.dependencies] section with either numpy = "==1.26.4" or numpy = "==2.0.2", then run the tests as usual:
$ pixi run -e test-minimum tests

EDIT VeckoTheGecko: Using fixes #issue_number so that issues are automatically closed on merge

@VeckoTheGecko
Copy link
Copy Markdown
Contributor

VeckoTheGecko commented Oct 6, 2025

Pinning NumPy to 2.1.0 is above the minimum shown in SPEC0

Let's pin numpy >2.1.0 and also have the other packages be more recent.

Let's scope this PR to not touch code, and just focus on the environments and CI. We can discuss/explore policy or adherance to SPEC0 in another issues/PRs (+ I would like some time to discuss with other maintainers to see how they handle SPEC0 :) ).

Can we do the following as well in this PR?:

  • Remove sklearn as core dependency #2304 (just made this)
  • I think you accidentally deleted a notebook here, if we can revert that
  • Can you update the [dependencies] section to have >={{version as listed in minimum environment}}
  • Can you update .github/ci/recipe.yaml to match
  • Add lower bounds to tqdm, cf_xarray, and pooch and test against them. pooch = ">=1.8.0", tqdm=">=4.50.0", cf_xarray = ">=0.8.5" should work .

@andrew-s28
Copy link
Copy Markdown
Contributor Author

@VeckoTheGecko Sounds good, thanks for your feedback.

The notebook was removed as per your comment in #2292, since this notebook was the only place remaining in Parcels with a SciPy dependency.

Can do on the rest!

@VeckoTheGecko
Copy link
Copy Markdown
Contributor

The notebook was removed as per your comment in #2292, since this notebook was the only place remaining in Parcels with a SciPy dependency.

Ah woops! I meant completely remove the dependency rather than moving it to the notebook environment :)) . If you could leave the notebook that would be great

@andrew-s28 andrew-s28 marked this pull request as ready for review October 7, 2025 19:51
@andrew-s28
Copy link
Copy Markdown
Contributor Author

@VeckoTheGecko I think I've addressed all the comments now and things may be ready to go - let me know if there's anything missing!

Matplotlib, trajan, platformdirs, and pytest do not need to be in the released verion. Let's use this recipe.yml as the universal source of truth as we develop v4
@VeckoTheGecko VeckoTheGecko changed the title Pins minimum dependencies and tests against them Test against minimum dependencies, update deps and recipe.yml Oct 8, 2025
@VeckoTheGecko VeckoTheGecko changed the title Test against minimum dependencies, update deps and recipe.yml Test against minimum dependencies, remove old deps Oct 8, 2025
@VeckoTheGecko VeckoTheGecko enabled auto-merge (squash) October 8, 2025 13:00
@VeckoTheGecko
Copy link
Copy Markdown
Contributor

This is awesome 🤩 - thanks @andrew-s28 🚀

@VeckoTheGecko VeckoTheGecko merged commit a1299f0 into Parcels-code:v4-dev Oct 8, 2025
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Oct 8, 2025
reint-fischer pushed a commit to reint-fischer/parcels that referenced this pull request Oct 15, 2025
Co-authored-by: Vecko <36369090+VeckoTheGecko@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Remove sklearn as core dependency Remove SciPy as a core dependency Test against minimum versions for dependencies

2 participants