summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-12-15 14:33:58 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-12-15 15:15:36 +0100
commit11f7741953c58daa3a1e7e24d929a25374bc9da2 (patch)
tree04c79103f82d183fcf4a782e1be27c428e6c5aa5
parentfe491ec65c468928d32e87c97dd275ba6da7a9d5 (diff)
downloadnumpy-11f7741953c58daa3a1e7e24d929a25374bc9da2.tar.gz
MAINT: Add `np.rec.array` overloads for `None` and file-like objects
-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"],
+))