summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatteo Raso <matteo_luigi_raso@protonmail.com>2023-01-18 02:25:00 -0500
committerMatteo Raso <matteo_luigi_raso@protonmail.com>2023-01-18 02:25:00 -0500
commit88cdaa21aea87ec7d56d1d583500ab2659a5e65e (patch)
treefef694437f5e163d7a06c56c39719fe811f643c2 /numpy
parent68d7aadd30cb7a4f6f32e76715b38b644df18602 (diff)
downloadnumpy-88cdaa21aea87ec7d56d1d583500ab2659a5e65e.tar.gz
BUG: Added __name__ atribute to vectorize class (#23021)
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/function_base.py1
-rw-r--r--numpy/lib/tests/test_function_base.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 7a69c3c81..27ed79044 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -2273,6 +2273,7 @@ class vectorize:
self.pyfunc = pyfunc
self.cache = cache
self.signature = signature
+ self.__name__ = pyfunc.__name__
self._ufunc = {} # Caching to improve default performance
if doc is None:
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index ecba35f2d..69e4c4848 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -1780,6 +1780,13 @@ class TestVectorize:
assert_equal(type(r), subclass)
assert_equal(r, m * v)
+ def test_name(self):
+ #See gh-23021
+ @np.vectorize
+ def f2(a, b):
+ return a + b
+
+ assert f2.__name__ == 'f2'
class TestLeaks:
class A: