From 8a0c57ad101b256a6231ab77d3449598a43a1b77 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Wed, 21 Jul 2021 17:16:29 -0400 Subject: [PATCH 01/11] Insecure String Comparison --- numpy/core/src/multiarray/descriptor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 58aa608c374a..2581cc4fe7d2 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1724,12 +1724,12 @@ _convert_from_str(PyObject *obj, int align) /* Check for a deprecated Numeric-style typecode */ /* `Uint` has deliberately weird uppercasing */ - char *dep_tps[] = {"Bytes", "Datetime64", "Str", "Uint"}; + char *dep_tps[] = {"Bytes0", "Datetime64", "Str0", "Uint32", "Uint64"}; int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]); for (int i = 0; i < ndep_tps; ++i) { char *dep_tp = dep_tps[i]; - if (strncmp(type, dep_tp, strlen(dep_tp)) == 0) { + if (strncmp(type, dep_tp, strlen(dep_tp)+1) == 0) { /* Deprecated 2020-06-09, NumPy 1.20 */ if (DEPRECATE("Numeric-style type codes are " "deprecated and will result in " From 9ccd1d081437acc557256998ada51874b0e21c6a Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Thu, 29 Jul 2021 11:29:35 -0400 Subject: [PATCH 02/11] Finished Deprecations --- numpy/core/numerictypes.py | 2 +- numpy/core/tests/test_deprecations.py | 14 +------------- numpy/core/tests/test_dtype.py | 6 +++--- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 12f424fd4167..d8156a0f0cfc 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -124,7 +124,7 @@ generic = allTypes['generic'] genericTypeRank = ['bool', 'int8', 'uint8', 'int16', 'uint16', - 'int32', 'uint32', 'int64', 'uint64', 'int128', + 'int32', 'int64', 'int128', 'uint128', 'float16', 'float32', 'float64', 'float80', 'float96', 'float128', 'float256', diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 42e632e4aa2a..d1c81bc116cd 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -314,19 +314,7 @@ def test_insufficient_width_negative(self): self.assert_deprecated(np.binary_repr, args=args, kwargs=kwargs) -class TestNumericStyleTypecodes(_DeprecationTestCase): - """ - Most numeric style typecodes were previously deprecated (and removed) - in 1.20. This also deprecates the remaining ones. - """ - # 2020-06-09, NumPy 1.20 - def test_all_dtypes(self): - deprecated_types = ['Bytes0', 'Datetime64', 'Str0'] - # Depending on intp size, either Uint32 or Uint64 is defined: - deprecated_types.append(f"U{np.dtype(np.intp).name}") - for dt in deprecated_types: - self.assert_deprecated(np.dtype, exceptions=(TypeError,), - args=(dt,)) + class TestDTypeAttributeIsDTypeDeprecation(_DeprecationTestCase): diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 4f52268f57a4..49ce2a3d5745 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -109,9 +109,9 @@ def test_richcompare_invalid_dtype_comparison(self, operation): operation(np.dtype(np.int32), 7) @pytest.mark.parametrize("dtype", - ['Bool', 'Complex32', 'Complex64', 'Float16', 'Float32', 'Float64', - 'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Timedelta64', - 'UInt8', 'UInt16', 'UInt32', 'UInt64', 'Void0', + ['Bool', 'Bytes0', 'Complex32', 'Complex64', 'Datetime64', 'Float16', 'Float32', 'Float64', + 'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Str0', 'Timedelta64', + 'UInt8', 'UInt16', 'Uint32', 'UInt32', 'Uint64', 'UInt64', 'Void0', "Float128", "Complex128"]) def test_numeric_style_types_are_invalid(self, dtype): with assert_raises(TypeError): From 1553c9ec57117afeeeff22c054b25c372f68ee5c Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Fri, 30 Jul 2021 09:39:41 -0400 Subject: [PATCH 03/11] Breaks numpy types --- numpy/core/_type_aliases.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py index 67addef483f6..3765a0d34e18 100644 --- a/numpy/core/_type_aliases.py +++ b/numpy/core/_type_aliases.py @@ -115,15 +115,6 @@ def _add_aliases(): # add forward, reverse, and string mapping to numarray sctypeDict[char] = info.type - # Add deprecated numeric-style type aliases manually, at some point - # we may want to deprecate the lower case "bytes0" version as well. - for name in ["Bytes0", "Datetime64", "Str0", "Uint32", "Uint64"]: - if english_lower(name) not in allTypes: - # Only one of Uint32 or Uint64, aliases of `np.uintp`, was (and is) defined, note that this - # is not UInt32/UInt64 (capital i), which is removed. - continue - allTypes[name] = allTypes[english_lower(name)] - sctypeDict[name] = sctypeDict[english_lower(name)] _add_aliases() From b6198e125a66644ddb7bb158aebf3997f68c75a4 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Fri, 30 Jul 2021 10:50:09 -0400 Subject: [PATCH 04/11] Removed elements in dep_tps --- numpy/core/src/multiarray/descriptor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 2581cc4fe7d2..b81760934a3f 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1724,7 +1724,7 @@ _convert_from_str(PyObject *obj, int align) /* Check for a deprecated Numeric-style typecode */ /* `Uint` has deliberately weird uppercasing */ - char *dep_tps[] = {"Bytes0", "Datetime64", "Str0", "Uint32", "Uint64"}; + char *dep_tps[] = {}; int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]); for (int i = 0; i < ndep_tps; ++i) { char *dep_tp = dep_tps[i]; From 15e6cccc3ba0e5809ae75fabc113a9e38365ae60 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Fri, 30 Jul 2021 15:59:13 -0400 Subject: [PATCH 05/11] Delete Typecode Comment --- numpy/core/src/multiarray/descriptor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index b81760934a3f..639204bc9d28 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1722,7 +1722,7 @@ _convert_from_str(PyObject *obj, int align) goto fail; } - /* Check for a deprecated Numeric-style typecode */ + /* `Uint` has deliberately weird uppercasing */ char *dep_tps[] = {}; int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]); From 2973f8bb0c9fca71b3530ca669e11c7a9bd21e09 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Fri, 30 Jul 2021 16:09:54 -0400 Subject: [PATCH 06/11] Deleted for loop --- numpy/core/src/multiarray/descriptor.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 639204bc9d28..35fd78ecd1ff 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1723,21 +1723,6 @@ _convert_from_str(PyObject *obj, int align) } - /* `Uint` has deliberately weird uppercasing */ - char *dep_tps[] = {}; - int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]); - for (int i = 0; i < ndep_tps; ++i) { - char *dep_tp = dep_tps[i]; - - if (strncmp(type, dep_tp, strlen(dep_tp)+1) == 0) { - /* Deprecated 2020-06-09, NumPy 1.20 */ - if (DEPRECATE("Numeric-style type codes are " - "deprecated and will result in " - "an error in the future.") < 0) { - goto fail; - } - } - } /* * Probably only ever dispatches to `_convert_from_type`, but who * knows what users are injecting into `np.typeDict`. From e1b86b831291a55f2f14732e93070df4276171d1 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Mon, 2 Aug 2021 11:16:14 -0400 Subject: [PATCH 07/11] Fixed 80 characters or more issue --- numpy/core/src/multiarray/descriptor.c | 1 - numpy/core/tests/test_dtype.py | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 35fd78ecd1ff..f2f1f35fe02d 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1722,7 +1722,6 @@ _convert_from_str(PyObject *obj, int align) goto fail; } - /* * Probably only ever dispatches to `_convert_from_type`, but who * knows what users are injecting into `np.typeDict`. diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 49ce2a3d5745..23269f01bebe 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -109,9 +109,12 @@ def test_richcompare_invalid_dtype_comparison(self, operation): operation(np.dtype(np.int32), 7) @pytest.mark.parametrize("dtype", - ['Bool', 'Bytes0', 'Complex32', 'Complex64', 'Datetime64', 'Float16', 'Float32', 'Float64', - 'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Str0', 'Timedelta64', - 'UInt8', 'UInt16', 'Uint32', 'UInt32', 'Uint64', 'UInt64', 'Void0', + ['Bool', 'Bytes0', 'Complex32', 'Complex64', + 'Datetime64', 'Float16', 'Float32', 'Float64', + 'Int8', 'Int16', 'Int32', 'Int64', + 'Object0', 'Str0', 'Timedelta64', + 'UInt8', 'UInt16', 'Uint32', 'UInt32', + 'Uint64', 'UInt64', 'Void0', "Float128", "Complex128"]) def test_numeric_style_types_are_invalid(self, dtype): with assert_raises(TypeError): From 062b55c01fe91f8ec357d305eaa4b3f9b39f6ce4 Mon Sep 17 00:00:00 2001 From: Kevin Granados Date: Mon, 2 Aug 2021 15:04:49 -0400 Subject: [PATCH 08/11] Expired Release Note --- doc/release/upcoming_changes/19539.expired.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/release/upcoming_changes/19539.expired.rst diff --git a/doc/release/upcoming_changes/19539.expired.rst b/doc/release/upcoming_changes/19539.expired.rst new file mode 100644 index 000000000000..3b2f5013522c --- /dev/null +++ b/doc/release/upcoming_changes/19539.expired.rst @@ -0,0 +1,3 @@ +The deprecation of numeric style type-codes ``np.Bytes0``, +``np.Datetime64``, ``np.Str0``, ``np.Uint32`` and ``np.Uint64`` +is expired. These have been removed from the public API. From 68d9283d8984f326343d67071e12e01b7b243814 Mon Sep 17 00:00:00 2001 From: coredesignsbg <> Date: Wed, 4 Aug 2021 21:25:03 +0000 Subject: [PATCH 09/11] Updated Release Note --- doc/release/upcoming_changes/19539.expired.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/release/upcoming_changes/19539.expired.rst b/doc/release/upcoming_changes/19539.expired.rst index 3b2f5013522c..6e94f175d85c 100644 --- a/doc/release/upcoming_changes/19539.expired.rst +++ b/doc/release/upcoming_changes/19539.expired.rst @@ -1,3 +1,2 @@ -The deprecation of numeric style type-codes ``np.Bytes0``, -``np.Datetime64``, ``np.Str0``, ``np.Uint32`` and ``np.Uint64`` -is expired. These have been removed from the public API. +* Using the strings ``"Bytes0"``, ``"Datetime64"``, ``"Str0"``, ``"Uint32"``, + and ``"Uint64"`` as a dtype will now raise a ``TypeError``. \ No newline at end of file From 1025934d20846fb4e91263321175c187e68d62f7 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Tue, 10 Aug 2021 12:34:25 -0700 Subject: [PATCH 10/11] Update numpy/core/numerictypes.py --- numpy/core/numerictypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index d8156a0f0cfc..12f424fd4167 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -124,7 +124,7 @@ generic = allTypes['generic'] genericTypeRank = ['bool', 'int8', 'uint8', 'int16', 'uint16', - 'int32', 'int64', 'int128', + 'int32', 'uint32', 'int64', 'uint64', 'int128', 'uint128', 'float16', 'float32', 'float64', 'float80', 'float96', 'float128', 'float256', From aec964fa36a1d4e0113cc06747d1587a989beaf8 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Tue, 10 Aug 2021 14:39:34 -0700 Subject: [PATCH 11/11] Update numpy/core/tests/test_deprecations.py --- numpy/core/tests/test_deprecations.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index d1c81bc116cd..44a3ed74a1dc 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -314,9 +314,6 @@ def test_insufficient_width_negative(self): self.assert_deprecated(np.binary_repr, args=args, kwargs=kwargs) - - - class TestDTypeAttributeIsDTypeDeprecation(_DeprecationTestCase): # Deprecated 2021-01-05, NumPy 1.21 message = r".*`.dtype` attribute" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy