summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2018-07-13 23:51:14 -0500
committerGitHub <noreply@github.com>2018-07-13 23:51:14 -0500
commitc8b246cee7d01c45fb80f765b06abff433ff46da (patch)
treecf884d124e9471f2727419c4b2e0ea147658c050 /numpy/core
parentb047f387d2424bd2134db6005190311b15a84ac2 (diff)
parent7c3f590d925e2ff68f2852ef1e3211b5452a8d9f (diff)
downloadnumpy-c8b246cee7d01c45fb80f765b06abff433ff46da.tar.gz
Merge pull request #11382 from mattip/remove-typeNA
DEP: deprecate undocumented, unused dtype type dicts
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numerictypes.py18
-rw-r--r--numpy/core/tests/test_deprecations.py7
-rw-r--r--numpy/core/tests/test_regression.py8
3 files changed, 27 insertions, 6 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 727fb66d1..817af4c7b 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -92,7 +92,7 @@ from numpy.core.multiarray import (
datetime_as_string, busday_offset, busday_count, is_busday,
busdaycalendar
)
-
+from numpy._globals import VisibleDeprecationWarning
# we add more at the bottom
__all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes',
@@ -210,8 +210,20 @@ def english_capitalize(s):
sctypeDict = {} # Contains all leaf-node scalar types with aliases
-sctypeNA = {} # Contails all leaf-node types -> numarray type equivalences
-allTypes = {} # Collect the types we will add to the module here
+class TypeNADict(dict):
+ def __getitem__(self, key):
+ # 2018-06-24, 1.16
+ warnings.warn('sctypeNA and typeNA will be removed in v1.18 '
+ 'of numpy', VisibleDeprecationWarning, stacklevel=2)
+ return dict.__getitem__(self, key)
+ def get(self, key, default=None):
+ # 2018-06-24, 1.16
+ warnings.warn('sctypeNA and typeNA will be removed in v1.18 '
+ 'of numpy', VisibleDeprecationWarning, stacklevel=2)
+ return dict.get(self, key, default)
+
+sctypeNA = TypeNADict() # Contails all leaf-node types -> numarray type equivalences
+allTypes = {} # Collect the types we will add to the module here
# separate the actual type info from the abtract base classes
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 8eb258666..0e7e9f55a 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -504,3 +504,10 @@ class TestGeneratorSum(_DeprecationTestCase):
# 2018-02-25, 1.15.0
def test_generator_sum(self):
self.assert_deprecated(np.sum, args=((i for i in range(5)),))
+
+class TestSctypeNA(_VisibleDeprecationTestCase):
+ # 2018-06-24, 1.16
+ def test_sctypeNA(self):
+ self.assert_deprecated(lambda: np.sctypeNA['?'])
+ self.assert_deprecated(lambda: np.typeNA['?'])
+ self.assert_deprecated(lambda: np.typeNA.get('?'))
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 62f592524..5f4410d54 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -46,9 +46,11 @@ class TestRegression(object):
assert_array_equal(a, b)
def test_typeNA(self):
- # Ticket #31
- assert_equal(np.typeNA[np.int64], 'Int64')
- assert_equal(np.typeNA[np.uint64], 'UInt64')
+ # Issue gh-515
+ with suppress_warnings() as sup:
+ sup.filter(np.VisibleDeprecationWarning)
+ assert_equal(np.typeNA[np.int64], 'Int64')
+ assert_equal(np.typeNA[np.uint64], 'UInt64')
def test_dtype_names(self):
# Ticket #35