Repository navigation
Conversation
Collaborator
|
— codex on behalf of Ralf — I checked both cases below on with-GIL and free-threaded CPython 3.14.10 with NumPy 2.5.5.
Ralf has yet to review these findings. |
…ngth-1 axis A const Ref with fully dynamic strides got the source array back from ensure() and then failed the stride check. Force a copy in that case. This also lets such a Ref accept an array with negative strides. A stride that is not a multiple of the scalar size is now ignored on an axis of length 1, because that stride is never used. Assisted-by: ClaudeCode:claude-fable-5-2
Collaborator
Author
|
🤖 AI text below 🤖 I reproduced both points on CPython 3.14.7 with NumPy 2.5.5. Both are fixed in 7aa9acc.
The new assertions failed before the fix. I updated the PR description and the changelog entry. |
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.
🤖 AI text below 🤖
EigenProps::conformabledivided the numpy byte strides bysizeof(Scalar)with integerdivision. A stride that is not a whole number of scalars was truncated. A field of a packed
structured array (for example
np.zeros(4, dtype=[('a', 'f8'), ('b', 'i1')])['a'], which has astride of 9 bytes) was thus seen as contiguous, and a mutable
Eigen::Refread and wrote theneighbouring field.
The conformability result now records such strides. A mutable
Eigen::Refrefuses the array, andby-value and
const Refarguments copy it, as they already do for negative strides. The stride ofan axis of length 1 is not used, so it is not checked.
A
const Refwith fully dynamic strides (py::EigenDRef<const M>) did not copy, becausearray_t::ensurereturns the source array when the dtype is correct. The caster now forces acopy in that case. This also fixes the same failure for negative strides.
Fixes item 5 of #6159.
Suggested changelog entry:
size, which let a mutable
Eigen::Refcorrupt neighbouring data. AconstEigen::Refwith fully dynamic strides now copies such arrays, and arrays with negative strides, instead of
raising
TypeError.