summaryrefslogtreecommitdiff
path: root/numpy/tests/typing/fail
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-12-13 14:14:49 -0700
committerGitHub <noreply@github.com>2020-12-13 14:14:49 -0700
commit3fe2d9d2627fc0f84aeed293ff8afa7c1f08d899 (patch)
tree2ea27fe06a19c39e8d7a5fe2f87cb7e05363247d /numpy/tests/typing/fail
parent7d7e446fcbeeff70d905bde2eb0264a797488280 (diff)
parenteff302e5e8678fa17fb3d8156d49eb585b0876d9 (diff)
downloadnumpy-3fe2d9d2627fc0f84aeed293ff8afa7c1f08d899.tar.gz
Merge branch 'master' into fix-issue-10244
Diffstat (limited to 'numpy/tests/typing/fail')
-rw-r--r--numpy/tests/typing/fail/array_like.py16
-rw-r--r--numpy/tests/typing/fail/fromnumeric.py126
-rw-r--r--numpy/tests/typing/fail/ndarray.py11
-rw-r--r--numpy/tests/typing/fail/numerictypes.py13
-rw-r--r--numpy/tests/typing/fail/scalars.py81
-rw-r--r--numpy/tests/typing/fail/simple.py10
-rw-r--r--numpy/tests/typing/fail/ufuncs.py7
-rw-r--r--numpy/tests/typing/fail/warnings_and_errors.py7
8 files changed, 0 insertions, 271 deletions
diff --git a/numpy/tests/typing/fail/array_like.py b/numpy/tests/typing/fail/array_like.py
deleted file mode 100644
index a97e72dc7..000000000
--- a/numpy/tests/typing/fail/array_like.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import numpy as np
-from numpy.typing import ArrayLike
-
-
-class A:
- pass
-
-
-x1: ArrayLike = (i for i in range(10)) # E: Incompatible types in assignment
-x2: ArrayLike = A() # E: Incompatible types in assignment
-x3: ArrayLike = {1: "foo", 2: "bar"} # E: Incompatible types in assignment
-
-scalar = np.int64(1)
-scalar.__array__(dtype=np.float64) # E: Unexpected keyword argument
-array = np.array([1])
-array.__array__(dtype=np.float64) # E: Unexpected keyword argument
diff --git a/numpy/tests/typing/fail/fromnumeric.py b/numpy/tests/typing/fail/fromnumeric.py
deleted file mode 100644
index 66f8a89d0..000000000
--- a/numpy/tests/typing/fail/fromnumeric.py
+++ /dev/null
@@ -1,126 +0,0 @@
-"""Tests for :mod:`numpy.core.fromnumeric`."""
-
-import numpy as np
-
-A = np.array(True, ndmin=2, dtype=bool)
-A.setflags(write=False)
-
-a = np.bool_(True)
-
-np.take(a, None) # E: No overload variant of "take" matches argument type
-np.take(a, axis=1.0) # E: No overload variant of "take" matches argument type
-np.take(A, out=1) # E: No overload variant of "take" matches argument type
-np.take(A, mode="bob") # E: No overload variant of "take" matches argument type
-
-np.reshape(a, None) # E: Argument 2 to "reshape" has incompatible type
-np.reshape(A, 1, order="bob") # E: Argument "order" to "reshape" has incompatible type
-
-np.choose(a, None) # E: No overload variant of "choose" matches argument type
-np.choose(a, out=1.0) # E: No overload variant of "choose" matches argument type
-np.choose(A, mode="bob") # E: No overload variant of "choose" matches argument type
-
-np.repeat(a, None) # E: Argument 2 to "repeat" has incompatible type
-np.repeat(A, 1, axis=1.0) # E: Argument "axis" to "repeat" has incompatible type
-
-np.swapaxes(A, None, 1) # E: Argument 2 to "swapaxes" has incompatible type
-np.swapaxes(A, 1, [0]) # E: Argument 3 to "swapaxes" has incompatible type
-
-np.transpose(A, axes=1.0) # E: Argument "axes" to "transpose" has incompatible type
-
-np.partition(a, None) # E: Argument 2 to "partition" has incompatible type
-np.partition(
- a, 0, axis="bob" # E: Argument "axis" to "partition" has incompatible type
-)
-np.partition(
- A, 0, kind="bob" # E: Argument "kind" to "partition" has incompatible type
-)
-np.partition(
- A, 0, order=range(5) # E: Argument "order" to "partition" has incompatible type
-)
-
-np.argpartition( # E: No overload variant of "argpartition" matches argument type
- a, None
-)
-np.argpartition( # E: No overload variant of "argpartition" matches argument type
- a, 0, axis="bob"
-)
-np.argpartition( # E: No overload variant of "argpartition" matches argument type
- A, 0, kind="bob"
-)
-np.argpartition(
- A, 0, order=range(5) # E: Argument "order" to "argpartition" has incompatible type
-)
-
-np.sort(A, axis="bob") # E: Argument "axis" to "sort" has incompatible type
-np.sort(A, kind="bob") # E: Argument "kind" to "sort" has incompatible type
-np.sort(A, order=range(5)) # E: Argument "order" to "sort" has incompatible type
-
-np.argsort(A, axis="bob") # E: Argument "axis" to "argsort" has incompatible type
-np.argsort(A, kind="bob") # E: Argument "kind" to "argsort" has incompatible type
-np.argsort(A, order=range(5)) # E: Argument "order" to "argsort" has incompatible type
-
-np.argmax(A, axis="bob") # E: No overload variant of "argmax" matches argument type
-np.argmax(A, kind="bob") # E: No overload variant of "argmax" matches argument type
-
-np.argmin(A, axis="bob") # E: No overload variant of "argmin" matches argument type
-np.argmin(A, kind="bob") # E: No overload variant of "argmin" matches argument type
-
-np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
- A[0], 0, side="bob"
-)
-np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
- A[0], 0, sorter=1.0
-)
-
-np.resize(A, 1.0) # E: Argument 2 to "resize" has incompatible type
-
-np.squeeze(A, 1.0) # E: No overload variant of "squeeze" matches argument type
-
-np.diagonal(A, offset=None) # E: Argument "offset" to "diagonal" has incompatible type
-np.diagonal(A, axis1="bob") # E: Argument "axis1" to "diagonal" has incompatible type
-np.diagonal(A, axis2=[]) # E: Argument "axis2" to "diagonal" has incompatible type
-
-np.trace(A, offset=None) # E: Argument "offset" to "trace" has incompatible type
-np.trace(A, axis1="bob") # E: Argument "axis1" to "trace" has incompatible type
-np.trace(A, axis2=[]) # E: Argument "axis2" to "trace" has incompatible type
-
-np.ravel(a, order="bob") # E: Argument "order" to "ravel" has incompatible type
-
-np.compress(
- [True], A, axis=1.0 # E: Argument "axis" to "compress" has incompatible type
-)
-
-np.clip(a, 1, 2, out=1) # E: No overload variant of "clip" matches argument type
-np.clip(1, None, None) # E: No overload variant of "clip" matches argument type
-
-np.sum(a, axis=1.0) # E: No overload variant of "sum" matches argument type
-np.sum(a, keepdims=1.0) # E: No overload variant of "sum" matches argument type
-np.sum(a, initial=[1]) # E: No overload variant of "sum" matches argument type
-
-np.all(a, axis=1.0) # E: No overload variant of "all" matches argument type
-np.all(a, keepdims=1.0) # E: No overload variant of "all" matches argument type
-np.all(a, out=1.0) # E: No overload variant of "all" matches argument type
-
-np.any(a, axis=1.0) # E: No overload variant of "any" matches argument type
-np.any(a, keepdims=1.0) # E: No overload variant of "any" matches argument type
-np.any(a, out=1.0) # E: No overload variant of "any" matches argument type
-
-np.cumsum(a, axis=1.0) # E: Argument "axis" to "cumsum" has incompatible type
-np.cumsum(a, dtype=1.0) # E: Argument "dtype" to "cumsum" has incompatible type
-np.cumsum(a, out=1.0) # E: Argument "out" to "cumsum" has incompatible type
-
-np.ptp(a, axis=1.0) # E: No overload variant of "ptp" matches argument type
-np.ptp(a, keepdims=1.0) # E: No overload variant of "ptp" matches argument type
-np.ptp(a, out=1.0) # E: No overload variant of "ptp" matches argument type
-
-np.amax(a, axis=1.0) # E: No overload variant of "amax" matches argument type
-np.amax(a, keepdims=1.0) # E: No overload variant of "amax" matches argument type
-np.amax(a, out=1.0) # E: No overload variant of "amax" matches argument type
-np.amax(a, initial=[1.0]) # E: No overload variant of "amax" matches argument type
-np.amax(a, where=[1.0]) # E: List item 0 has incompatible type
-
-np.amin(a, axis=1.0) # E: No overload variant of "amin" matches argument type
-np.amin(a, keepdims=1.0) # E: No overload variant of "amin" matches argument type
-np.amin(a, out=1.0) # E: No overload variant of "amin" matches argument type
-np.amin(a, initial=[1.0]) # E: No overload variant of "amin" matches argument type
-np.amin(a, where=[1.0]) # E: List item 0 has incompatible type
diff --git a/numpy/tests/typing/fail/ndarray.py b/numpy/tests/typing/fail/ndarray.py
deleted file mode 100644
index 5a5130d40..000000000
--- a/numpy/tests/typing/fail/ndarray.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import numpy as np
-
-# Ban setting dtype since mutating the type of the array in place
-# makes having ndarray be generic over dtype impossible. Generally
-# users should use `ndarray.view` in this situation anyway. See
-#
-# https://github.com/numpy/numpy-stubs/issues/7
-#
-# for more context.
-float_array = np.array([1.0])
-float_array.dtype = np.bool_ # E: Property "dtype" defined in "ndarray" is read-only
diff --git a/numpy/tests/typing/fail/numerictypes.py b/numpy/tests/typing/fail/numerictypes.py
deleted file mode 100644
index dd03eacc1..000000000
--- a/numpy/tests/typing/fail/numerictypes.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import numpy as np
-
-# Techincally this works, but probably shouldn't. See
-#
-# https://github.com/numpy/numpy/issues/16366
-#
-np.maximum_sctype(1) # E: incompatible type "int"
-
-np.issubsctype(1, np.int64) # E: incompatible type "int"
-
-np.issubdtype(1, np.int64) # E: incompatible type "int"
-
-np.find_common_type(np.int64, np.int64) # E: incompatible type "Type[int64]"
diff --git a/numpy/tests/typing/fail/scalars.py b/numpy/tests/typing/fail/scalars.py
deleted file mode 100644
index 5d7221895..000000000
--- a/numpy/tests/typing/fail/scalars.py
+++ /dev/null
@@ -1,81 +0,0 @@
-import numpy as np
-
-# Construction
-
-np.float32(3j) # E: incompatible type
-
-# Technically the following examples are valid NumPy code. But they
-# are not considered a best practice, and people who wish to use the
-# stubs should instead do
-#
-# np.array([1.0, 0.0, 0.0], dtype=np.float32)
-# np.array([], dtype=np.complex64)
-#
-# See e.g. the discussion on the mailing list
-#
-# https://mail.python.org/pipermail/numpy-discussion/2020-April/080566.html
-#
-# and the issue
-#
-# https://github.com/numpy/numpy-stubs/issues/41
-#
-# for more context.
-np.float32([1.0, 0.0, 0.0]) # E: incompatible type
-np.complex64([]) # E: incompatible type
-
-np.complex64(1, 2) # E: Too many arguments
-# TODO: protocols (can't check for non-existent protocols w/ __getattr__)
-
-np.datetime64(0) # E: non-matching overload
-
-dt_64 = np.datetime64(0, "D")
-td_64 = np.timedelta64(1, "h")
-
-dt_64 + dt_64 # E: Unsupported operand types
-
-td_64 - dt_64 # E: Unsupported operand types
-td_64 / dt_64 # E: No overload
-td_64 % 1 # E: Unsupported operand types
-td_64 % dt_64 # E: Unsupported operand types
-
-
-class A:
- def __float__(self):
- return 1.0
-
-
-np.int8(A()) # E: incompatible type
-np.int16(A()) # E: incompatible type
-np.int32(A()) # E: incompatible type
-np.int64(A()) # E: incompatible type
-np.uint8(A()) # E: incompatible type
-np.uint16(A()) # E: incompatible type
-np.uint32(A()) # E: incompatible type
-np.uint64(A()) # E: incompatible type
-
-np.void("test") # E: incompatible type
-
-np.generic(1) # E: Cannot instantiate abstract class
-np.number(1) # E: Cannot instantiate abstract class
-np.integer(1) # E: Cannot instantiate abstract class
-np.signedinteger(1) # E: Cannot instantiate abstract class
-np.unsignedinteger(1) # E: Cannot instantiate abstract class
-np.inexact(1) # E: Cannot instantiate abstract class
-np.floating(1) # E: Cannot instantiate abstract class
-np.complexfloating(1) # E: Cannot instantiate abstract class
-np.character("test") # E: Cannot instantiate abstract class
-np.flexible(b"test") # E: Cannot instantiate abstract class
-
-np.float64(value=0.0) # E: Unexpected keyword argument
-np.int64(value=0) # E: Unexpected keyword argument
-np.uint64(value=0) # E: Unexpected keyword argument
-np.complex128(value=0.0j) # E: Unexpected keyword argument
-np.str_(value='bob') # E: No overload variant
-np.bytes_(value=b'test') # E: No overload variant
-np.void(value=b'test') # E: Unexpected keyword argument
-np.bool_(value=True) # E: Unexpected keyword argument
-np.datetime64(value="2019") # E: No overload variant
-np.timedelta64(value=0) # E: Unexpected keyword argument
-
-np.bytes_(b"hello", encoding='utf-8') # E: No overload variant
-np.str_("hello", encoding='utf-8') # E: No overload variant
diff --git a/numpy/tests/typing/fail/simple.py b/numpy/tests/typing/fail/simple.py
deleted file mode 100644
index b5e9d1b13..000000000
--- a/numpy/tests/typing/fail/simple.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Simple expression that should fail with mypy."""
-
-import numpy as np
-
-# Array creation routines checks
-np.zeros("test") # E: incompatible type
-np.zeros() # E: Too few arguments
-
-np.ones("test") # E: incompatible type
-np.ones() # E: Too few arguments
diff --git a/numpy/tests/typing/fail/ufuncs.py b/numpy/tests/typing/fail/ufuncs.py
deleted file mode 100644
index 4da9d08ba..000000000
--- a/numpy/tests/typing/fail/ufuncs.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import numpy as np
-
-np.sin.nin + "foo" # E: Unsupported operand types
-np.sin(1, foo="bar") # E: Unexpected keyword argument
-np.sin(1, extobj=["foo", "foo", "foo"]) # E: incompatible type
-
-np.abs(None) # E: incompatible type
diff --git a/numpy/tests/typing/fail/warnings_and_errors.py b/numpy/tests/typing/fail/warnings_and_errors.py
deleted file mode 100644
index 7390cc45f..000000000
--- a/numpy/tests/typing/fail/warnings_and_errors.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import numpy as np
-
-np.AxisError(1.0) # E: Argument 1 to "AxisError" has incompatible type
-np.AxisError(1, ndim=2.0) # E: Argument "ndim" to "AxisError" has incompatible type
-np.AxisError(
- 2, msg_prefix=404 # E: Argument "msg_prefix" to "AxisError" has incompatible type
-)