8000 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
API: Change isfortran to f-contig and not c-contig
This was a check for 1-d arrays, this is the generalization to
higher dimension if we allow higher dimensioal arrays to be both
f- and c-contiguous.
  • Loading branch information
seberg committed Oct 21, 2012
commit 4b281479db093a55c010610ad287c75beb6da13b
7 changes: 4 additions & 3 deletions numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
#define NPY_ARRAY_F_CONTIGUOUS 0x0002

/*
* Note: all 0-d arrays are C_CONTIGUOUS and F_CONTIGUOUS. If a
* 1-d array is C_CONTIGUOUS it is also F_CONTIGUOUS
* 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
* one axis has a dimension different from one (ie. a 1x3x1 array).
*/

/*
Expand Down Expand Up @@ -1370,7 +1371,7 @@ PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS))

#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) && \
(PyArray_NDIM(m) > 1))
(!PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS)))

#define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) ? \
NPY_ARRAY_F_CONTIGUOUS : 0))
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def require(a, dtype=None, requirements=None):
def isfortran(a):
"""
Returns True if array is arranged in Fortran-order in memory
and dimension > 1.
and not C-order.

Parameters
----------
Expand Down Expand Up @@ -584,7 +584,7 @@ def isfortran(a):
>>> np.isfortran(b)
True

1-D arrays always evaluate as False.
C-ordered arrays evaluate as False even if they are also FORTRAN-ordered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here look correct, but I wanted to note that this function is really strange and confusing. IMO we should deprecate isfortran (and ISFORTRAN) altogether.


>>> np.isfortran(np.array([1, 2], order='FORTRAN'))
False
Expand Down
0