Repository navigation
Stack - Upgrade numpy version - #23
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Point-model integer arrays are incompatible with the new memoryviews, and the NumPy constraint removal conflicts with repository guidance.
2 open findings
What changed in this PR
Refactors Python/C array exchange to use zero-copy typed memoryviews and broadens NumPy build compatibility.
Changes:
- Enforces contiguous
float64state arrays. - Replaces copied output buffers with direct memoryviews.
- Removes the NumPy version cap and disables deprecated C APIs.
| File | Description |
|---|---|
setup.py |
Defines the non-deprecated NumPy C API. |
pysnobal/ipysnobal.py |
Normalizes initialized state arrays. |
pysnobal/c_snobal/snobal.pyx |
Passes output arrays directly to C. |
pyproject.toml |
Removes the NumPy build-version constraint. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jomey
force-pushed
the
copilot/research-update-python-numpy
branch
6 times, most recently
from
October 21, 2026 21:50
228e6a8 to
7d45812
Compare
jomey
enabled auto-merge
October 21, 2026 21:55
jomey
force-pushed
the
copilot/research-update-python-numpy
branch
from
October 21, 2026 22:03
ea72b20 to
6e667ee
Compare
Member
Author
|
To get the tests passing we first must work on an updated conda environment. |
jomey
commented
Oct 28, 2026
jomey
commented
Oct 28, 2026
jomey
commented
Oct 28, 2026
From Copilot: Use typed memoryviews in do_tstep_grid for NumPy 2.x compatibility Replace all `cdef np.ndarray[dtype, mode="c", ndim=2]` buffer declarations with typed memoryviews (`double[:, ::1]` / `int[:, ::1]`) and remove the `np.PyArray_SimpleNewFromData` / `np.npy_intp` C-API calls. Write-back of C results now uses a direct memoryview slice-assignment.
From @copilot: Defining NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION tells NumPy's headers: "compile against only the stable post-1.7 API." This is the same API surface that NumPy 2.x retains — the symbols that were removed in 2.0 are a strict subset of what was already deprecated before 1.7. Placing the macro in setup.py's Extension definition means it is applied uniformly to every .c file compiled in that extension (including the libsnobal C sources), not just the Cython-generated one.
…contiguousarray from hot path
Also clean up other calls from legacy setup. Remove codecov or tox clean up artifacts.
Update the initializer of a point execution to initialize all arrays as float64
Change one call to calculate timesteps and use a syntax that is friendly with Pandas up to 3.0
Enables use of the `pip install --group dev` call for dev setups
It is not out yet (and not sure if even planned), but makes for less surprises of a future maintainer
Remove unused targets and consolidate clean targets. Also update doc strings.
This makes it compatible with version > 3 Warning Message: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
The entire iSnobal stack (AWSM, SMRF, topocalc) was recently upgraded to support 3.14
jomey
force-pushed
the
copilot/research-update-python-numpy
branch
from
October 28, 2026 18:48
362f1f2 to
7a26894
Compare
Starting with 3.1, pandas is warning for this soon deprecated option.
jomey
commented
Oct 28, 2026
jomey
commented
Oct 28, 2026
Contributor
PR Completed: iSnobal/model_setup@e94c1bd |
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.


This pull request refactors how NumPy arrays are passed between Python and C code.
The main change is to use direct typed-memoryview views into NumPy arrays instead of making copies, ensuring that the C code writes directly into the output arrays. C-contiguous arrays and correct dtype is now enforced at initialization.
Array Handling Improvements:
pysnobal/c_snobal/snobal.pyx: Replaced repeated use ofnp.ascontiguousarrayandPyArray_SimpleNewFromDatawith direct typed-memoryview views for all float64 output arrays. Special handling is retained for arrays that require dtype conversion, such asmaskandlayer_count. [1] [2]pysnobal/ipysnobal.py: Modified initialization to enforce float64 C-contiguous layout for all arrays in the state dictionary, ensuring compatibility with the new memoryview approach and preventing silent loss of written-back state.Build and Compatibility Updates:
setup.py: AddedNPY_NO_DEPRECATED_APImacro to suppress warnings about deprecated NumPy C API usage.Minor Code Cleanup:
pysnobal/c_snobal/snobal.pyx: Minor formatting and cleanup in the calculation of air pressure.AWSM dependency
The corresponding PR to update the test suite is here: iSnobal/awsm#44
Should be re-run after this is merged.
Python version
This now supports Python 3.14, Numpy 2.5, and Pandas 3.1