From 321e028b90526ec40df281ae543f18aa4434bcd3 Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Sat, 7 Aug 2021 11:05:40 +0530 Subject: Shifted to CopyMode to np.array_api --- numpy/array_api.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 numpy/array_api.py (limited to 'numpy/array_api.py') diff --git a/numpy/array_api.py b/numpy/array_api.py new file mode 100644 index 000000000..527ccc3fa --- /dev/null +++ b/numpy/array_api.py @@ -0,0 +1,24 @@ +import enum + +__all__ = [ + 'CopyMode' + ] + +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.array_api' -- cgit v1.2.1