summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorbernie gray <bfgray3@users.noreply.github.com>2020-11-18 14:14:13 -0500
committerGitHub <noreply@github.com>2020-11-18 13:14:13 -0600
commit8fee756d8c9d2f5fe211fd9feb999c0da8a89821 (patch)
treea1529887d7a2485f129917dd8373da955c47c2cd /numpy
parent2884e617b2d93010707525071c4308c3356fb8cc (diff)
downloadnumpy-8fee756d8c9d2f5fe211fd9feb999c0da8a89821.tar.gz
BUG: ensure _UFuncNoLoopError can be pickled (#17377)
* BUG: ensure _UFuncNoLoopError can be pickled; closes #16490 * update quickstart.rst * add round trip pickle test * move _ArrayMemoryError picking test
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_exceptions.py2
-rw-r--r--numpy/core/tests/test__exceptions.py16
2 files changed, 16 insertions, 2 deletions
diff --git a/numpy/core/_exceptions.py b/numpy/core/_exceptions.py
index 99172e23d..5e17ed3b2 100644
--- a/numpy/core/_exceptions.py
+++ b/numpy/core/_exceptions.py
@@ -26,8 +26,6 @@ def _display_as_base(cls):
"""
assert issubclass(cls, Exception)
cls.__name__ = cls.__base__.__name__
- cls.__qualname__ = cls.__base__.__qualname__
- set_module(cls.__base__.__module__)(cls)
return cls
diff --git a/numpy/core/tests/test__exceptions.py b/numpy/core/tests/test__exceptions.py
index 494b51f34..51c056936 100644
--- a/numpy/core/tests/test__exceptions.py
+++ b/numpy/core/tests/test__exceptions.py
@@ -1,11 +1,21 @@
"""
Tests of the ._exceptions module. Primarily for exercising the __str__ methods.
"""
+
+import pickle
+
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
+_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
class TestArrayMemoryError:
+ def test_pickling(self):
+ """ Test that _ArrayMemoryError can be pickled """
+ error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
+ res = pickle.loads(pickle.dumps(error))
+ assert res._total_size == error._total_size
+
def test_str(self):
e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
str(e) # not crashing is enough
@@ -40,3 +50,9 @@ class TestArrayMemoryError:
e = _ArrayMemoryError((2, 4), np.dtype((np.uint64, 16)))
assert e._total_size == 1024
+
+
+class TestUFuncNoLoopError:
+ def test_pickling(self):
+ """ Test that _UFuncNoLoopError can be pickled """
+ assert isinstance(pickle.dumps(_UFuncNoLoopError), bytes)