diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-06-12 14:18:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 14:18:53 +0300 |
commit | 5345c2575a28fa2dfbbec83c99636669476c2745 (patch) | |
tree | 65b590d4ef7d573d8df663058a130a38b991da9f | |
parent | 9eabe2f87dbe087e878983bdd69edd8a9084c358 (diff) | |
parent | 8190116aa2fa58aba628b0a5cea768017acf82bf (diff) | |
download | numpy-5345c2575a28fa2dfbbec83c99636669476c2745.tar.gz |
Merge pull request #16574 from person142/dtype-constructor-types
MAINT: fix name of first parameter to dtype constructor in type stubs
-rw-r--r-- | numpy/__init__.pyi | 7 | ||||
-rw-r--r-- | numpy/core/_add_newdocs.py | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_dtype.py | 6 | ||||
-rw-r--r-- | numpy/tests/typing/pass/dtype.py | 3 |
4 files changed, 16 insertions, 4 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 2e9c28821..4aab0bbfa 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -51,7 +51,12 @@ _NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray) class dtype: names: Optional[Tuple[str, ...]] - def __init__(self, obj: DtypeLike, align: bool = ..., copy: bool = ...) -> None: ... + def __init__( + self, + dtype: DtypeLike, + align: bool = ..., + copy: bool = ..., + ) -> None: ... def __eq__(self, other: DtypeLike) -> bool: ... def __ne__(self, other: DtypeLike) -> bool: ... def __gt__(self, other: DtypeLike) -> bool: ... diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 31585779b..d0ed3d381 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -5141,7 +5141,7 @@ add_newdoc('numpy.core', 'ufunc', ('at', add_newdoc('numpy.core.multiarray', 'dtype', """ - dtype(obj, align=False, copy=False) + dtype(dtype, align=False, copy=False) Create a data type object. @@ -5151,7 +5151,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', Parameters ---------- - obj + dtype Object to be converted to a data type object. align : bool, optional Add padding to the fields to match what a C compiler would output diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index faea8688c..2e2b0dbe2 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -1056,6 +1056,11 @@ def test_invalid_dtype_string(): assert_raises(TypeError, np.dtype, u'Fl\xfcgel') +def test_keyword_argument(): + # test for https://github.com/numpy/numpy/pull/16574#issuecomment-642660971 + assert np.dtype(dtype=np.float64) == np.dtype(np.float64) + + class TestFromDTypeAttribute: def test_simple(self): class dt: @@ -1333,4 +1338,3 @@ class TestFromCTypes: pair_type = np.dtype('{},{}'.format(*pair)) expected = np.dtype([('f0', pair[0]), ('f1', pair[1])]) assert_equal(pair_type, expected) - diff --git a/numpy/tests/typing/pass/dtype.py b/numpy/tests/typing/pass/dtype.py new file mode 100644 index 000000000..f954fdd44 --- /dev/null +++ b/numpy/tests/typing/pass/dtype.py @@ -0,0 +1,3 @@ +import numpy as np + +np.dtype(dtype=np.int64) |