From 505b0f4c11acb1ade1e91f1360ffa6a33cbd0b51 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 19 Jun 2015 19:54:15 -0600 Subject: MAINT: Mark deprecation warning with a date and Numpy version. This is to make it easier to find and remove deprecated features. It would be a good idea if all deprecations were made with similar comments. --- numpy/core/arrayprint.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'numpy/core/arrayprint.py') diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 2dc56928c..1fa0849a8 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -291,6 +291,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \ "will be removed in 2.1. Use the `formatter` kw instead." import warnings + # 2011-04-03, RemoveMe warnings.warn(msg, DeprecationWarning) except AttributeError: # find the right formatting function for the array @@ -446,6 +447,7 @@ def array2string(a, max_line_width=None, precision=None, "2.0 and will be removed in 2.1. Use the " \ "`formatter` kw instead." import warnings + # 2012-05-11, RemoveMe warnings.warn(msg, DeprecationWarning) except AttributeError: if isinstance(x, tuple): -- cgit v1.2.1 From e1693d4ee1833eb0c07269da78712d529e71d943 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 14:04:36 -0600 Subject: DEP,MAINT: Remove support for a._format array printing. Deprecated, removed from numpy/core/arrayprint.py. --- numpy/core/arrayprint.py | 71 ++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 44 deletions(-) (limited to 'numpy/core/arrayprint.py') diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 1fa0849a8..4a9765639 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -286,39 +286,31 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', if key in fkeys: formatdict[key] = formatter[key] - try: - format_function = a._format - msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \ - "will be removed in 2.1. Use the `formatter` kw instead." - import warnings - # 2011-04-03, RemoveMe - warnings.warn(msg, DeprecationWarning) - except AttributeError: - # find the right formatting function for the array - dtypeobj = a.dtype.type - if issubclass(dtypeobj, _nt.bool_): - format_function = formatdict['bool'] - elif issubclass(dtypeobj, _nt.integer): - if issubclass(dtypeobj, _nt.timedelta64): - format_function = formatdict['timedelta'] - else: - format_function = formatdict['int'] - elif issubclass(dtypeobj, _nt.floating): - if issubclass(dtypeobj, _nt.longfloat): - format_function = formatdict['longfloat'] - else: - format_function = formatdict['float'] - elif issubclass(dtypeobj, _nt.complexfloating): - if issubclass(dtypeobj, _nt.clongfloat): - format_function = formatdict['longcomplexfloat'] - else: - format_function = formatdict['complexfloat'] - elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)): - format_function = formatdict['numpystr'] - elif issubclass(dtypeobj, _nt.datetime64): - format_function = formatdict['datetime'] + # find the right formatting function for the array + dtypeobj = a.dtype.type + if issubclass(dtypeobj, _nt.bool_): + format_function = formatdict['bool'] + elif issubclass(dtypeobj, _nt.integer): + if issubclass(dtypeobj, _nt.timedelta64): + format_function = formatdict['timedelta'] + else: + format_function = formatdict['int'] + elif issubclass(dtypeobj, _nt.floating): + if issubclass(dtypeobj, _nt.longfloat): + format_function = formatdict['longfloat'] else: - format_function = formatdict['numpystr'] + format_function = formatdict['float'] + elif issubclass(dtypeobj, _nt.complexfloating): + if issubclass(dtypeobj, _nt.clongfloat): + format_function = formatdict['longcomplexfloat'] + else: + format_function = formatdict['complexfloat'] + elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)): + format_function = formatdict['numpystr'] + elif issubclass(dtypeobj, _nt.datetime64): + format_function = formatdict['datetime'] + else: + format_function = formatdict['numpystr'] # skip over "[" next_line_prefix = " " @@ -441,18 +433,9 @@ def array2string(a, max_line_width=None, precision=None, if a.shape == (): x = a.item() - try: - lst = a._format(x) - msg = "The `_format` attribute is deprecated in Numpy " \ - "2.0 and will be removed in 2.1. Use the " \ - "`formatter` kw instead." - import warnings - # 2012-05-11, RemoveMe - warnings.warn(msg, DeprecationWarning) - except AttributeError: - if isinstance(x, tuple): - x = _convert_arrays(x) - lst = style(x) + if isinstance(x, tuple): + x = _convert_arrays(x) + lst = style(x) elif reduce(product, a.shape) == 0: # treat as a null array if any of shape elements == 0 lst = "[]" -- cgit v1.2.1