Skip to content

Commit 457663e

Browse files
committed
MAINT: ma.asanyarray: use order=None as default
1 parent 933fd54 commit 457663e

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

numpy/ma/core.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8616,7 +8616,7 @@ def asarray(a, dtype=None, order=None):
86168616
subok=False, order=order)
86178617

86188618

8619-
def asanyarray(a, dtype=None, order='A'):
8619+
def asanyarray(a, dtype=None, order=None):
86208620
"""
86218621
Convert the input to a masked array, conserving subclasses.
86228622
@@ -8629,14 +8629,13 @@ def asanyarray(a, dtype=None, order='A'):
86298629
Input data, in any form that can be converted to an array.
86308630
dtype : dtype, optional
86318631
By default, the data-type is inferred from the input data.
8632-
order : {'C', 'F', 'A'}, optional
8633-
Specify the order of the array. If order is 'C', then the array
8634-
will be in C-contiguous order (last-index varies the fastest).
8635-
If order is 'F', then the returned array will be in
8636-
Fortran-contiguous order (first-index varies the fastest).
8637-
If order is 'A' (default), then the returned array may be
8638-
in any order (either C-, Fortran-contiguous, or even discontiguous),
8639-
unless a copy is required, in which case it will be C-contiguous.
8632+
order : {'C', 'F', 'A', 'K'}, optional
8633+
Memory layout. 'A' and 'K' depend on the order of input array ``a``.
8634+
'C' row-major (C-style),
8635+
'F' column-major (Fortran-style) memory representation.
8636+
'A' (any) means 'F' if ``a`` is Fortran contiguous, 'C' otherwise
8637+
'K' (keep) preserve input order
8638+
Defaults to 'K'.
86408639
86418640
Returns
86428641
-------
@@ -8670,7 +8669,7 @@ def asanyarray(a, dtype=None, order='A'):
86708669
isinstance(a, MaskedArray)
86718670
and (dtype is None or dtype == a.dtype)
86728671
and (
8673-
order == 'A'
8672+
order in {None, 'A', 'K'}
86748673
or order == 'C' and a.flags.carray
86758674
or order == 'F' and a.flags.f_contiguous
86768675
)

numpy/ma/core.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,13 +2453,13 @@ def asarray(a: object, dtype: DTypeLike | None = None, order: _OrderKACF | None
24532453

24542454
# keep in sync with `asarray` (but note the additional first overload)
24552455
@overload
2456-
def asanyarray(a: _MArrayT, dtype: None = None, order: _OrderACF = "A") -> _MArrayT: ...
2456+
def asanyarray(a: _MArrayT, dtype: None = None, order: _OrderKACF | None = None) -> _MArrayT: ...
24572457
@overload
2458-
def asanyarray(a: _ArrayLike[_ScalarT], dtype: None = None, order: _OrderACF = "A") -> _MaskedArray[_ScalarT]: ...
2458+
def asanyarray(a: _ArrayLike[_ScalarT], dtype: None = None, order: _OrderKACF | None = None) -> _MaskedArray[_ScalarT]: ...
24592459
@overload
2460-
def asanyarray(a: object, dtype: _DTypeLike[_ScalarT], order: _OrderACF = "A") -> _MaskedArray[_ScalarT]: ...
2460+
def asanyarray(a: object, dtype: _DTypeLike[_ScalarT], order: _OrderKACF | None = None) -> _MaskedArray[_ScalarT]: ...
24612461
@overload
2462-
def asanyarray(a: object, dtype: DTypeLike | None = None, order: _OrderACF = "A") -> _MaskedArray[_ScalarT]: ...
2462+
def asanyarray(a: object, dtype: DTypeLike | None = None, order: _OrderKACF | None = None) -> _MaskedArray[_ScalarT]: ...
24632463

24642464
#
24652465
def is_masked(x: object) -> bool: ...

0 commit comments

Comments
 (0)