Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eeef9d4

Browse filesBrowse files
NectDzseberg
andauthored
DEP: Remove deprecated numeric style dtype strings (#19539)
Finishes the deprecation, and effectively closes gh-18993 * Insecure String Comparison * Finished Deprecations * Breaks numpy types * Removed elements in dep_tps * Delete Typecode Comment * Deleted for loop * Fixed 80 characters or more issue * Expired Release Note * Updated Release Note * Update numpy/core/numerictypes.py * Update numpy/core/tests/test_deprecations.py Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
1 parent c4e20ec commit eeef9d4
Copy full SHA for eeef9d4

File tree

Expand file treeCollapse file tree

5 files changed

+8
-43
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+8
-43
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Using the strings ``"Bytes0"``, ``"Datetime64"``, ``"Str0"``, ``"Uint32"``,
2+
and ``"Uint64"`` as a dtype will now raise a ``TypeError``.

‎numpy/core/_type_aliases.py

Copy file name to clipboardExpand all lines: numpy/core/_type_aliases.py
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,6 @@ def _add_aliases():
115115
# add forward, reverse, and string mapping to numarray
116116
sctypeDict[char] = info.type
117117

118-
# Add deprecated numeric-style type aliases manually, at some point
119-
# we may want to deprecate the lower case "bytes0" version as well.
120-
for name in ["Bytes0", "Datetime64", "Str0", "Uint32", "Uint64"]:
121-
if english_lower(name) not in allTypes:
122-
# Only one of Uint32 or Uint64, aliases of `np.uintp`, was (and is) defined, note that this
123-
# is not UInt32/UInt64 (capital i), which is removed.
124-
continue
125-
allTypes[name] = allTypes[english_lower(name)]
126-
sctypeDict[name] = sctypeDict[english_lower(name)]
127118

128119
_add_aliases()
129120

‎numpy/core/src/multiarray/descriptor.c

Copy file name to clipboardExpand all lines: numpy/core/src/multiarray/descriptor.c
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,22 +1723,6 @@ _convert_from_str(PyObject *obj, int align)
17231723
goto fail;
17241724
}
17251725

1726-
/* Check for a deprecated Numeric-style typecode */
1727-
/* `Uint` has deliberately weird uppercasing */
1728-
char *dep_tps[] = {"Bytes", "Datetime64", "Str", "Uint"};
1729-
int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]);
1730-
for (int i = 0; i < ndep_tps; ++i) {
1731-
char *dep_tp = dep_tps[i];
1732-
1733-
if (strncmp(type, dep_tp, strlen(dep_tp)) == 0) {
1734-
/* Deprecated 2020-06-09, NumPy 1.20 */
1735-
if (DEPRECATE("Numeric-style type codes are "
1736-
"deprecated and will result in "
1737-
"an error in the future.") < 0) {
1738-
goto fail;
1739-
}
1740-
}
1741-
}
17421726
/*
17431727
* Probably only ever dispatches to `_convert_from_type`, but who
17441728
* knows what users are injecting into `np.typeDict`.

‎numpy/core/tests/test_deprecations.py

Copy file name to clipboardExpand all lines: numpy/core/tests/test_deprecations.py
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,21 +314,6 @@ def test_insufficient_width_negative(self):
314314
self.assert_deprecated(np.binary_repr, args=args, kwargs=kwargs)
315315

316316

317-
class TestNumericStyleTypecodes(_DeprecationTestCase):
318-
"""
319-
Most numeric style typecodes were previously deprecated (and removed)
320-
in 1.20. This also deprecates the remaining ones.
321-
"""
322-
# 2020-06-09, NumPy 1.20
323-
def test_all_dtypes(self):
324-
deprecated_types = ['Bytes0', 'Datetime64', 'Str0']
325-
# Depending on intp size, either Uint32 or Uint64 is defined:
326-
deprecated_types.append(f"U{np.dtype(np.intp).name}")
327-
for dt in deprecated_types:
328-
self.assert_deprecated(np.dtype, exceptions=(TypeError,),
329-
args=(dt,))
330-
331-
332317
class TestDTypeAttributeIsDTypeDeprecation(_DeprecationTestCase):
333318
# Deprecated 2021-01-05, NumPy 1.21
334319
message = r".*`.dtype` attribute"

‎numpy/core/tests/test_dtype.py

Copy file name to clipboardExpand all lines: numpy/core/tests/test_dtype.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ def test_richcompare_invalid_dtype_comparison(self, operation):
109109
operation(np.dtype(np.int32), 7)
110110

111111
@pytest.mark.parametrize("dtype",
112-
['Bool', 'Complex32', 'Complex64', 'Float16', 'Float32', 'Float64',
113-
'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Timedelta64',
114-
'UInt8', 'UInt16', 'UInt32', 'UInt64', 'Void0',
112+
['Bool', 'Bytes0', 'Complex32', 'Complex64',
113+
'Datetime64', 'Float16', 'Float32', 'Float64',
114+
'Int8', 'Int16', 'Int32', 'Int64',
115+
'Object0', 'Str0', 'Timedelta64',
116+
'UInt8', 'UInt16', 'Uint32', 'UInt32',
117+
'Uint64', 'UInt64', 'Void0',
115118
"Float128", "Complex128"])
116119
def test_numeric_style_types_are_invalid(self, dtype):
117120
with assert_raises(TypeError):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.