8000 TYP: Type ``MaskedArray.ravel`` (#28848) · r-devulap/numpy@01fc740 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01fc740

Browse files
authored
TYP: Type MaskedArray.ravel (numpy#28848)
1 parent 20a4635 commit 01fc740

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

numpy/ma/core.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class MaskedArray(ndarray[_ShapeT_co, _DTypeT_co]):
484484
@overload
485485
def count(self, axis: _ShapeLike | None, keepdims: Literal[True]) -> NDArray[int_]: ...
486486

487-
def ravel(self, order=...): ...
487+
def ravel(self, order: _OrderKACF = "C") -> MaskedArray[tuple[int], _DTypeT_co]: ...
488488
def reshape(self, *s, **kwargs): ...
489489
def resize(self, newshape, refcheck=..., order=...): ...
490490
def put(self, indices: _ArrayLikeInt_co, values: ArrayLike, mode: _ModeKind = "raise") -> None: ...

numpy/typing/tests/data/reveal/ma.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ assert_type(np.ma.allclose(AR_f4, MAR_f4), bool)
283283
assert_type(np.ma.allclose(AR_f4, MAR_f4, masked_equal=False), bool)
284284
assert_type(np.ma.allclose(AR_f4, MAR_f4, rtol=.4, atol=.3), bool)
285285

286+
assert_type(MAR_2d_f4.ravel(), np.ma.MaskedArray[tuple[int], np.dtype[np.float32]])
287+
assert_type(MAR_1d.ravel(order='A'), np.ma.MaskedArray[tuple[int], np.dtype[Any]])
288+
286289
assert_type(np.ma.getmask(MAR_f4), NDArray[np.bool] | np.bool)
287290
# PyRight detects this one correctly, but mypy doesn't:
288291
# `Revealed type is "Union[numpy.ndarray[Any, Any], numpy.bool[Any]]"`

0 commit comments

Comments
 (0)
0