summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/records.pyi54
-rw-r--r--numpy/typing/tests/data/reveal/rec.pyi21
2 files changed, 75 insertions, 0 deletions
diff --git a/numpy/core/records.pyi b/numpy/core/records.pyi
index fda118276..172bab3ee 100644
--- a/numpy/core/records.pyi
+++ b/numpy/core/records.pyi
@@ -181,3 +181,57 @@ def array(
byteorder: None | _ByteOrder = ...,
copy: bool = ...,
) -> _RecArray[record]: ...
+@overload
+def array(
+ obj: None,
+ dtype: DTypeLike,
+ shape: _ShapeLike,
+ offset: int = ...,
+ formats: None = ...,
+ names: None = ...,
+ titles: None = ...,
+ aligned: bool = ...,
+ byteorder: None = ...,
+ copy: bool = ...,
+) -> _RecArray[Any]: ...
+@overload
+def array(
+ obj: None,
+ dtype: None = ...,
+ *,
+ shape: _ShapeLike,
+ offset: int = ...,
+ formats: DTypeLike,
+ names: None | str | Sequence[str] = ...,
+ titles: None | str | Sequence[str] = ...,
+ aligned: bool = ...,
+ byteorder: None | _ByteOrder = ...,
+ copy: bool = ...,
+) -> _RecArray[record]: ...
+@overload
+def array(
+ obj: _SupportsReadInto,
+ dtype: DTypeLike,
+ shape: None | _ShapeLike = ...,
+ offset: int = ...,
+ formats: None = ...,
+ names: None = ...,
+ titles: None = ...,
+ aligned: bool = ...,
+ byteorder: None = ...,
+ copy: bool = ...,
+) -> _RecArray[Any]: ...
+@overload
+def array(
+ obj: _SupportsReadInto,
+ dtype: None = ...,
+ shape: None | _ShapeLike = ...,
+ offset: int = ...,
+ *,
+ formats: DTypeLike,
+ names: None | str | Sequence[str] = ...,
+ titles: None | str | Sequence[str] = ...,
+ aligned: bool = ...,
+ byteorder: None | _ByteOrder = ...,
+ copy: bool = ...,
+) -> _RecArray[record]: ...
diff --git a/numpy/typing/tests/data/reveal/rec.pyi b/numpy/typing/tests/data/reveal/rec.pyi
index bf51c82a3..9921621f1 100644
--- a/numpy/typing/tests/data/reveal/rec.pyi
+++ b/numpy/typing/tests/data/reveal/rec.pyi
@@ -104,3 +104,24 @@ reveal_type(np.rec.array( # recarray[Any, dtype[record]]
formats=[np.int64, np.float64],
names=["i8", "f8"]
))
+
+reveal_type(np.rec.array( # recarray[Any, dtype[Any]]
+ None,
+ dtype=np.float64,
+ shape=(10, 3),
+))
+reveal_type(np.rec.array( # recarray[Any, dtype[Any]]
+ None,
+ formats=[np.int64, np.float64],
+ names=["i8", "f8"],
+ shape=(10, 3),
+))
+reveal_type(np.rec.array( # recarray[Any, dtype[Any]]
+ file_obj,
+ dtype=np.float64,
+))
+reveal_type(np.rec.array( # recarray[Any, dtype[Any]]
+ file_obj,
+ formats=[np.int64, np.float64],
+ names=["i8", "f8"],
+))