summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuya Unno <unnonouno@gmail.com>2020-06-22 03:32:36 +0900
committerGitHub <noreply@github.com>2020-06-21 11:32:36 -0700
commite481335697ec7dd69e22f2b073fe91e7af4ecaaa (patch)
tree0f9f014f6f93602f8164ae2d50229030ad503934
parent13a48995f56c507e1a493b18cdb18f892892759e (diff)
downloadnumpy-e481335697ec7dd69e22f2b073fe91e7af4ecaaa.tar.gz
ENH: add annotation for abs (#16618)
`numpy.abs` is alias of `numpy.absolute`. I added its type annotation.
-rw-r--r--numpy/__init__.pyi2
-rw-r--r--numpy/tests/typing/fail/ufuncs.py2
-rw-r--r--numpy/tests/typing/pass/ufuncs.py2
3 files changed, 6 insertions, 0 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index f9218391e..8de9cce02 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -824,6 +824,8 @@ tanh: ufunc
true_divide: ufunc
trunc: ufunc
+abs = absolute
+
# Warnings
class ModuleDeprecationWarning(DeprecationWarning): ...
class VisibleDeprecationWarning(UserWarning): ...
diff --git a/numpy/tests/typing/fail/ufuncs.py b/numpy/tests/typing/fail/ufuncs.py
index b178a4ea4..4da9d08ba 100644
--- a/numpy/tests/typing/fail/ufuncs.py
+++ b/numpy/tests/typing/fail/ufuncs.py
@@ -3,3 +3,5 @@ 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/pass/ufuncs.py b/numpy/tests/typing/pass/ufuncs.py
index c81ac48d1..82172952a 100644
--- a/numpy/tests/typing/pass/ufuncs.py
+++ b/numpy/tests/typing/pass/ufuncs.py
@@ -9,3 +9,5 @@ np.sin(1, extobj=[16, 1, lambda: None])
np.sin(1) + np.sin(1)
np.sin.types[0]
np.sin.__name__
+
+np.abs(np.array([1]))