Conversation
Under pandas 3.0, where Copy-on-Write is the default, the boolean masks built from `(_storage_type.str.lower() == 'functional').values` are read-only views. The storage-area/volume kernels are compiled eagerly with a `boolean[:]` signature, which numba treats as writable-only, so SuperLink construction fails with "No matching definition ... readonly array(bool, 1d, C)". Copy the masks with np.array(), which is accepted under pandas 2 and 3 and keeps the kernels' eager signatures. Fixes mdbartos#74 (cherry picked from commit e8fd854)
`_Sf_method_ik` was built as `Series.astype(np.int64).values`, so unlike the `.values.astype(...)` pattern used everywhere else it was never copied; under pandas 3 (Copy-on-Write) it is a read-only view and numba_b_ik, compiled with an eager `int64[:]` argument, rejects it during SuperLink.__init__. Copy it with np.array(). The same treatment for the geometry/transect/storage index arrays taken with `.loc[...].values` and for the tabular-storage index arrays, which reach kernels on code paths the basic examples do not exercise. Refs mdbartos#74 (cherry picked from commit 8294e6d)
This branch has not been deployed
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.
Fixes #74.
Under pandas 3.0, where Copy-on-Write is the default,
.valueson a Series or DataFrame is a read-only view. Several arrays built that way inSuperLink.__init__reach numba kernels compiled with eager, writable-only signatures (boolean[:],int64[:]), so construction fails withNo matching definition for argument type(s) ... readonly array(bool, 1d, C)(the storage-type masks) and, once past that,readonly array(int64, 1d, C)(_Sf_method_ik, built asSeries.astype(np.int64).valuesrather than.values.astype(...), so never copied).This copies those arrays with
np.array(...)at construction time: the two storage-type masks innsuperlink.pyandsuperlink.py,_Sf_method_ik, and the geometry/transect/storage index arrays taken with.loc[...].values. The kernels keep their eager signatures. Verified under pandas 3.0.5 and 2.x with a coupled ANUGA/pipedream model (mass balance closes) and a downstream test suite that previously failed on this.Independent of #73 (numpy 2
np.bool8); both are needed for a current numpy/pandas.