-
-
Notifications
You must be signed in to change notification settings - Fork 35k
gh-91484: Allow memoryview cast for F-contiguous #137803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| memoryview.cast() now allows casting from N-D to 1-D for F-contiguous. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1456,9 +1456,11 @@ memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, | |||||
| CHECK_RESTRICTED(self); | ||||||
|
|
||||||
| if (!MV_C_CONTIGUOUS(self->flags)) { | ||||||
| PyErr_SetString(PyExc_TypeError, | ||||||
| "memoryview: casts are restricted to C-contiguous views"); | ||||||
| return NULL; | ||||||
| if(shape || self->view.ndim == 1 || !MV_F_CONTIGUOUS(self->flags)) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed space, and
Suggested change
|
||||||
| PyErr_SetString(PyExc_TypeError, | ||||||
| "memoryview: casts are restricted to C-contiguous views"); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is now slightly misleading, since F-contiguous -> 1D is allowed. Maybe just "contiguous views"?
Suggested change
|
||||||
| return NULL; | ||||||
| } | ||||||
| } | ||||||
| if ((shape || self->view.ndim != 1) && zero_in_shape(self)) { | ||||||
| PyErr_SetString(PyExc_TypeError, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.