Replace np.NaN with np.nan for numpy 2.x compatibility#156
Merged
Conversation
NumPy 2.0 removed `np.NaN` (the deprecated capitalized alias) in
favor of `np.nan` (the canonical lowercase form, which always
existed). This notebook had one usage:
vel_angle[np.abs(vel_angle) > 100] = np.NaN # remove artifacts
This was the only thing keeping the file pinned to `numpy<2` — with
this fix, the notebook works against the current Colab runtime's
`numpy==2.0.2` without needing a kernel restart on install.
(Auto-added cell IDs in the same diff are an nbformat-write
normalization, not a content change.)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
|
Preview for this PR has been removed (PR closed). |
bendichter
added a commit
to catalystneuro/example-notebooks
that referenced
this pull request
May 14, 2026
…i#156) The lock generated by PR dandi#159 pinned `numpy==1.26.4` because the PR-141-era input deps included `numpy>=1.26,<2`. That cap was there because the notebook used `np.NaN` (removed in numpy 2.0). PR dandi#156 already replaced `np.NaN` with `np.nan`, so the cap is now stale and the notebook code is numpy-2.x clean. Re-resolved with `numpy>=1.26` (no upper cap) against the Colab constraints set. The only line that changed is the numpy pin — everything else was already at Colab versions: numpy 1.26.4 -> 2.0.2 (matches Colab — no restart on install) Now the install on Colab is fully no-op for numpy/pandas/scipy/h5py/etc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
NumPy 2.0 removed the deprecated capitalized alias
np.NaNin favor ofnp.nan(the canonical lowercase form, which has always existed). Searching the repo:np.NaN: 1 notebook —000559/dattalab/markowitz_gillis_nature_2023/reproduce_figure1d.ipynb(one usage)np.NAN,np.Inf,np.product,np.cumproduct,np.sometrue,np.alltrue,np.float_,np.complex_,np.unicode_,np.cast: none in.ipynbfiles outside the (already-excluded) DataJoint subdirs.This PR converts the single occurrence:
That was the only thing keeping this notebook pinned to
numpy<2in #149's lockfile (the resolver dropped numpy from the Colab constraint set for this one becausenp.NaNis gone in numpy 2.x). After this lands, the next regen on #149 will pick upnumpy==2.0.2for this notebook, matching Colab — and Colab users won't need to restart the runtime on install.Notebooks NOT touched (and why)
Two other notebooks were also pinned to
numpy<2in #149's locks, but for unrelated reasons — they don't use any removed numpy APIs:000559/.../reproduce_figure_S1.ipynb— pinned because ofcellpose<4(cellpose 4.x dropped the oldCellposeclass the notebook uses). The numpy<2 is a transitive consequence of cellpose's deps, not a notebook-content issue.000582/Sargolini2006/000582_Sargolini2006_demo.ipynb— pinned viapynapple>=0.6transitive deps. Notebook code is numpy-2.x clean.Those two would need different fixes (cellpose modernization / pynapple version bump) and are out of scope here.
The diff also includes nbformat-added cell
idfields on a few previously-id-less cells — that's an automatic normalization on save, not a content change.🤖 Generated with Claude Code