10000 ENH: Make 1-dimensional axes not matter for contiguous flags by seberg · Pull Request #2694 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Make 1-dimensional axes not matter for contiguous flags #2694

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

Merged
merged 12 commits into from
Oct 25, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MNT: Minor cleanups in comments and lowlevel_strided_loops.
  • Loading branch information
seberg committed Oct 22, 2012
commit 4d741d282641ae7bd152ec6d89de8f24e9983267
2 changes: 1 addition & 1 deletion numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);

/*
* Note: all 0-d arrays are C_CONTIGUOUS and F_CONTIGUOUS. An N-d
* array that is C_CONTIGUOUS may also be F_CONTIGUOUS if only
* array that is C_CONTIGUOUS is also F_CONTIGUOUS if only
* one axis has a dimension different from one (ie. a 1x3x1 array).
*/

Expand Down
5 changes: 3 additions & 2 deletions numpy/core/src/multiarray/flagsobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)

/*
* Check whether the given array is stored contiguously
* in memory. And update the passed in ap apropriately.
* in memory. And update the passed in ap flags apropriately.
*
* 0-strided arrays are not contiguous. A dimension == 1 is always ok.
* A FD26 dimension == 1 stride is ignored for contiguous flags and a 0-sized array
* is always both C- and F-Contiguous. 0-strided arrays are not contiguous.
*/
static void
_UpdateContiguousFlags(PyArrayObject *ap)
Expand Down
12 changes: 6 additions & 6 deletions numpy/core/src/private/lowlevel_strided_loops.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp *shape,
stride = ((PyArray_NDIM(arr) == 0) ? 0 : \
((PyArray_NDIM(arr) == 1) ? \
PyArray_STRIDE(arr, 0) : \
PyArray_DESCR(arr)->elsize)) \
PyArray_ITEMSIZE(arr))) \


#define PyArray_TRIVIALLY_ITERABLE_PAIR(arr1, arr2) (\
Expand All @@ -577,10 +577,10 @@ PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp *shape,
data2 = PyArray_BYTES(arr2); \
stride1 = (size1 == 1 ? 0 : ((PyArray_NDIM(arr1) == 1) ? \
PyArray_STRIDE(arr1, 0) : \
PyArray_DESCR(arr1)->elsize)); \
PyArray_ITEMSIZE(arr1))); \
stride2 = (size2 == 1 ? 0 : ((PyArray_NDIM(arr2) == 1) ? \
PyArray_STRIDE(arr2, 0) : \
PyArray_DESCR(arr2)->elsize)); \
PyArray_ITEMSIZE(arr2))); \
}

#define PyArray_TRIVIALLY_ITERABLE_TRIPLE(arr1, arr2, arr3) (\
Expand Down Expand Up @@ -618,13 +618,13 @@ PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp *shape,
data3 = PyArray_BYTES(arr3); \
stride1 = (size1 == 1 ? 0 : ((PyArray_NDIM(arr1) == 1) ? \
PyArray_STRIDE(arr1, 0) : \
PyArray_DESCR(arr1)->elsize)); \
PyArray_ITEMSIZE(arr1))); \
stride2 = (size2 == 1 ? 0 : ((PyArray_NDIM(arr2) == 1) ? \
PyArray_STRIDE(arr2, 0) : \
PyArray_DESCR(arr2)->elsize)); \
PyArray_ITEMSIZE(arr2))); \
stride3 = (size3 == 1 ? 0 : ((PyArray_NDIM(arr3) == 1) ? \
PyArray_STRIDE(arr3, 0) : \
PyArray_DESCR(arr3)->elsize)); \
PyArray_ITEMSIZE(arr3))); \
}

#endif
0