diff options
Diffstat (limited to 'numpy/_globals.py')
-rw-r--r-- | numpy/_globals.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/numpy/_globals.py b/numpy/_globals.py index 2d7b69bc4..9a7b458f1 100644 --- a/numpy/_globals.py +++ b/numpy/_globals.py @@ -52,11 +52,25 @@ class VisibleDeprecationWarning(UserWarning): """ pass - -class _NoValue(object): +class _NoValueType(object): """Special keyword value. - This class may be used as the default value assigned to a deprecated - keyword in order to check if it has been given a user defined value. + The instance of this class may be used as the default value assigned to a + deprecated keyword in order to check if it has been given a user defined + value. """ - pass + __instance = None + def __new__(cls): + # ensure that only one instance exists + if not cls.__instance: + cls.__instance = super(_NoValueType, cls).__new__(cls) + return cls.__instance + + # needed for python 2 to preserve identity through a pickle + def __reduce__(self): + return (self.__class__, ()) + + def __repr__(self): + return "<no value>" + +_NoValue = _NoValueType() |