summaryrefslogtreecommitdiff
path: root/numpy/_globals.py
diff options
context:
space:
mode:
authorczgdp1807 <gdp.1807@gmail.com>2021-08-18 12:15:00 +0530
committerczgdp1807 <gdp.1807@gmail.com>2021-08-18 12:15:00 +0530
commit698fb6db917e63621df9e9d50335245dd0ab5a2e (patch)
tree381d2b7c6877300358b3a0b256fb74c8607d2df4 /numpy/_globals.py
parent0f8d4c5f23a5fa55efba96034c0215cb683f9e02 (diff)
downloadnumpy-698fb6db917e63621df9e9d50335245dd0ab5a2e.tar.gz
Made _CopyMode private
Diffstat (limited to 'numpy/_globals.py')
-rw-r--r--numpy/_globals.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/numpy/_globals.py b/numpy/_globals.py
index 5e8a4557a..fd8025443 100644
--- a/numpy/_globals.py
+++ b/numpy/_globals.py
@@ -15,9 +15,11 @@ That was not the case when the singleton classes were defined in the numpy
motivated this module.
"""
+import enum
+
__ALL__ = [
'ModuleDeprecationWarning', 'VisibleDeprecationWarning',
- '_NoValue'
+ '_NoValue', '_CopyMode'
]
@@ -90,3 +92,23 @@ class _NoValueType:
_NoValue = _NoValueType()
+
+
+class _CopyMode(enum.Enum):
+
+ ALWAYS = True
+ IF_NEEDED = False
+ NEVER = 2
+
+ def __bool__(self):
+ # For backwards compatiblity
+ if self == _CopyMode.ALWAYS:
+ return True
+
+ if self == _CopyMode.IF_NEEDED:
+ return False
+
+ raise TypeError(f"{self} is neither True nor False.")
+
+
+_CopyMode.__module__ = 'numpy' \ No newline at end of file