diff options
author | Sebastian Berg <sebastianb@nvidia.com> | 2022-12-05 18:14:25 +0100 |
---|---|---|
committer | Sebastian Berg <sebastianb@nvidia.com> | 2022-12-06 12:00:21 +0100 |
commit | 928a7b40a40941c0c282cfad78c3a6021422a71c (patch) | |
tree | 09baf0ae86a0f1be479e4a2ba2b088f633bbc942 /numpy/exceptions.py | |
parent | 297c66131f2a32ebb7dfb0aeb9d88d917a791430 (diff) | |
download | numpy-928a7b40a40941c0c282cfad78c3a6021422a71c.tar.gz |
API: Hide exceptions from the main namespace
I wasn't sure if we should already start deprecating the exceptions
so opted to follow up with only hiding them from `__dir__()` but
still having them in `__all__` and available.
This also changes their module to `numpy.exceptions`, which matters
because that is how they will be pickled (it would not be possible
to unpickle such an exception in an older NumPy version).
Due to pickling, we could put off changing the module.
Diffstat (limited to 'numpy/exceptions.py')
-rw-r--r-- | numpy/exceptions.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/numpy/exceptions.py b/numpy/exceptions.py index 721b8102e..ca0a47c04 100644 --- a/numpy/exceptions.py +++ b/numpy/exceptions.py @@ -35,7 +35,7 @@ Exceptions from ._utils import set_module as _set_module __all__ = [ - "ComplexWarning", "VisibleDeprecationWarning", + "ComplexWarning", "VisibleDeprecationWarning", "ModuleDeprecationWarning", "TooHardError", "AxisError", "DTypePromotionError"] @@ -52,7 +52,6 @@ _is_loaded = True # This then also means that the typing stubs should be moved! -@_set_module('numpy') class ComplexWarning(RuntimeWarning): """ The warning raised when casting a complex dtype to a real dtype. @@ -63,7 +62,7 @@ class ComplexWarning(RuntimeWarning): """ pass -@_set_module("numpy") + class ModuleDeprecationWarning(DeprecationWarning): """Module deprecation warning. @@ -80,7 +79,6 @@ class ModuleDeprecationWarning(DeprecationWarning): """ -@_set_module("numpy") class VisibleDeprecationWarning(UserWarning): """Visible deprecation warning. @@ -92,7 +90,6 @@ class VisibleDeprecationWarning(UserWarning): # Exception used in shares_memory() -@_set_module('numpy') class TooHardError(RuntimeError): """max_work was exceeded. @@ -106,7 +103,6 @@ class TooHardError(RuntimeError): pass -@_set_module('numpy') class AxisError(ValueError, IndexError): """Axis supplied was invalid. |