summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-01-02 16:51:42 -0500
committerCharles Harris <charlesr.harris@gmail.com>2015-01-02 16:51:42 -0500
commit7fbc43b98d59ef982671b456cebc229425ae7e4e (patch)
tree7f34064ec1facebc7ca341666ab9f0b53dd5e481 /numpy/ma/core.py
parentd2b6e96f48df28fe346c6ac6fa35b2ac324ef2f6 (diff)
parent78f69df28acd80654705a43bcf1e977b9c423b53 (diff)
downloadnumpy-7fbc43b98d59ef982671b456cebc229425ae7e4e.tar.gz
Merge pull request #5398 from Garrett-R/fix_5376
BUG: Fixes #5376: np.ravel to return same array type
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 9ca9136dd..bbaaaa3f1 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -4041,10 +4041,26 @@ class MaskedArray(ndarray):
#............................................
flatten = _arraymethod('flatten')
#
- def ravel(self):
+ def ravel(self, order='C'):
"""
Returns a 1D version of self, as a view.
+ Parameters
+ ----------
+ order : {'C', 'F', 'A', 'K'}, optional
+ The elements of `a` are read using this index order. 'C' means to
+ index the elements in C-like order, with the last axis index
+ changing fastest, back to the first axis index changing slowest.
+ 'F' means to index the elements in Fortran-like index order, with
+ the first index changing fastest, and the last index changing
+ slowest. Note that the 'C' and 'F' options take no account of the
+ memory layout of the underlying array, and only refer to the order
+ of axis indexing. 'A' means to read the elements in Fortran-like
+ index order if `m` is Fortran *contiguous* in memory, C-like order
+ otherwise. 'K' means to read the elements in the order they occur
+ in memory, except for reversing the data when strides are negative.
+ By default, 'C' index order is used.
+
Returns
-------
MaskedArray
@@ -4062,10 +4078,10 @@ class MaskedArray(ndarray):
[1 -- 3 -- 5 -- 7 -- 9]
"""
- r = ndarray.ravel(self._data).view(type(self))
+ r = ndarray.ravel(self._data, order=order).view(type(self))
r._update_from(self)
if self._mask is not nomask:
- r._mask = ndarray.ravel(self._mask).reshape(r.shape)
+ r._mask = ndarray.ravel(self._mask, order=order).reshape(r.shape)
else:
r._mask = nomask
return r