From aba6864dffb068d791db09648ebdbc9b3499fe0d Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:00:59 -0500 Subject: [PATCH 1/9] Deprecate Index.dtype_str --- doc/source/whatsnew/v0.25.0.rst | 2 ++ pandas/core/indexes/base.py | 5 +++++ pandas/tests/indexes/multi/test_format.py | 7 ++++--- pandas/tests/indexes/period/test_period.py | 14 ++++++++------ pandas/tests/indexes/test_common.py | 7 ++++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 1fe808e098860..b1916c9602f06 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -604,6 +604,8 @@ Other deprecations - The :meth:`Series.ftype`, :meth:`Series.ftypes` and :meth:`DataFrame.ftypes` methods are deprecated and will be removed in a future version. Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`). - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) +- :attr:`Index.dtype_str` is deprecated. (:issue:``) +- .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index cb5b4a6c8993c..9a1019cfb6897 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -690,7 +690,12 @@ def dtype(self): def dtype_str(self): """ Return the dtype str of the underlying data. + + .. deprecated:: 0.25.0 """ + warnings.warn('`dtype_str` has been deprecated. Call `str` on the ' + 'dtype attribute instead.', DeprecationWarning, + stacklevel=2) return str(self.dtype) def ravel(self, order='C'): diff --git a/pandas/tests/indexes/multi/test_format.py b/pandas/tests/indexes/multi/test_format.py index 8315478d85125..312ebf2a5d973 100644 --- a/pandas/tests/indexes/multi/test_format.py +++ b/pandas/tests/indexes/multi/test_format.py @@ -8,9 +8,10 @@ def test_dtype_str(indices): - dtype = indices.dtype_str - assert isinstance(dtype, str) - assert dtype == str(indices.dtype) + with tm.assert_produces_warning(DeprecationWarning): + dtype = indices.dtype_str + assert isinstance(dtype, str) + assert dtype == str(indices.dtype) def test_format(idx): diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index 2f3f15101e7ca..681497cfe2706 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -132,12 +132,14 @@ def test_shallow_copy_changing_freq_raises(self): def test_dtype_str(self): pi = pd.PeriodIndex([], freq='M') - assert pi.dtype_str == 'period[M]' - assert pi.dtype_str == str(pi.dtype) - - pi = pd.PeriodIndex([], freq='3M') - assert pi.dtype_str == 'period[3M]' - assert pi.dtype_str == str(pi.dtype) + with tm.assert_produces_warning(DeprecationWarning): + assert pi.dtype_str == 'period[M]' + assert pi.dtype_str == str(pi.dtype) + + with tm.assert_produces_warning(DeprecationWarning): + pi = pd.PeriodIndex([], freq='3M') + assert pi.dtype_str == 'period[3M]' + assert pi.dtype_str == str(pi.dtype) def test_view_asi8(self): idx = pd.PeriodIndex([], freq='M') diff --git a/pandas/tests/indexes/test_common.py b/pandas/tests/indexes/test_common.py index 451fb2ed7906d..c60b31e06f643 100644 --- a/pandas/tests/indexes/test_common.py +++ b/pandas/tests/indexes/test_common.py @@ -155,9 +155,10 @@ def test_set_name_methods(self, indices): assert indices.names == [name] def test_dtype_str(self, indices): - dtype = indices.dtype_str - assert isinstance(dtype, str) - assert dtype == str(indices.dtype) + with tm.assert_produces_warning(DeprecationWarning): + dtype = indices.dtype_str + assert isinstance(dtype, str) + assert dtype == str(indices.dtype) def test_hash_error(self, indices): index = indices From b9f21f3a380e77de359a1131dc659aa6d16a42a2 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:22:24 -0500 Subject: [PATCH 2/9] Remove imag/real --- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/core/nanops.py | 2 +- pandas/core/series.py | 8 ++++++++ pandas/core/util/hashing.py | 2 +- pandas/io/packers.py | 8 ++++---- pandas/tests/series/test_dtypes.py | 14 ++++++++++---- pandas/tests/test_nanops.py | 4 ++-- 7 files changed, 27 insertions(+), 13 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index b1916c9602f06..8220f8979ee86 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -605,7 +605,7 @@ Other deprecations Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`). - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) - :attr:`Index.dtype_str` is deprecated. (:issue:``) -- +- .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 834a3bc3d8bbb..cc8b241bedba1 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -1275,7 +1275,7 @@ def _ensure_numeric(x): except (TypeError, ValueError): x = x.astype(np.float64) else: - if not np.any(x.imag): + if not np.any(np.imag(x)): x = x.real elif not (is_float(x) or is_integer(x) or is_complex(x)): try: diff --git a/pandas/core/series.py b/pandas/core/series.py index 730a96f5435a1..813dc21148ec6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -793,7 +793,11 @@ def __array_prepare__(self, result, context=None): def real(self): """ Return the real value of vector. + + .. deprecated 0.25.0 """ + warnings.warn("`real` has be deprecated and will be removed in a " + "future verison", DeprecationWarning, stacklevel=2) return self.values.real @real.setter @@ -804,7 +808,11 @@ def real(self, v): def imag(self): """ Return imag value of vector. + + .. deprecated 0.25.0 """ + warnings.warn("`imag` has be deprecated and will be removed in a " + "future verison", DeprecationWarning, stacklevel=2) return self.values.imag @imag.setter diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 93074f5afa2b3..a916f2f06df21 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -269,7 +269,7 @@ def hash_array(vals, encoding='utf8', hash_key=None, categorize=True): # we'll be working with everything as 64-bit values, so handle this # 128-bit value early if np.issubdtype(dtype, np.complex128): - return hash_array(vals.real) + 23 * hash_array(vals.imag) + return hash_array(np.real(vals)) + 23 * hash_array(np.imag(vals)) # First, turn whatever array this is into unsigned 64-bit ints, if we can # manage it. diff --git a/pandas/io/packers.py b/pandas/io/packers.py index 4a273bfe2decb..cef0af3edbb20 100644 --- a/pandas/io/packers.py +++ b/pandas/io/packers.py @@ -523,16 +523,16 @@ def encode(obj): return {'typ': 'np_scalar', 'sub_typ': 'np_complex', 'dtype': obj.dtype.name, - 'real': obj.real.__repr__(), - 'imag': obj.imag.__repr__()} + 'real': np.real(obj).__repr__(), + 'imag': np.imag(obj).__repr__()} else: return {'typ': 'np_scalar', 'dtype': obj.dtype.name, 'data': obj.__repr__()} elif isinstance(obj, complex): return {'typ': 'np_complex', - 'real': obj.real.__repr__(), - 'imag': obj.imag.__repr__()} + 'real': np.real(obj).__repr__(), + 'imag': np.imag(obj).__repr__()} return obj diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 392163228398b..0d0cee79fcf5a 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -433,12 +433,18 @@ def test_complex(self): a = np.arange(5, dtype=np.float64) b = Series(a + 4j * a) - tm.assert_numpy_array_equal(a, b.real) - tm.assert_numpy_array_equal(4 * a, b.imag) + tm.assert_numpy_array_equal(a, np.real(b)) + tm.assert_numpy_array_equal(4 * a, np.imag(b)) b.real = np.arange(5) + 5 - tm.assert_numpy_array_equal(a + 5, b.real) - tm.assert_numpy_array_equal(4 * a, b.imag) + tm.assert_numpy_array_equal(a + 5, np.real(b)) + tm.assert_numpy_array_equal(4 * a, np.imag(b)) + + def test_real_imag_deprecated(self): + s = pd.Series([1]) + with tm.assert_produces_warning(DeprecationWarning): + s.imag + s.real def test_arg_for_errors_in_astype(self): # see gh-14878 diff --git a/pandas/tests/test_nanops.py b/pandas/tests/test_nanops.py index ad035f9c0158d..6e7b34a0632ad 100644 --- a/pandas/tests/test_nanops.py +++ b/pandas/tests/test_nanops.py @@ -144,9 +144,9 @@ def _coerce_tds(targ, res): # but nanops doesn't, so make that an exception elif targ.dtype.kind == 'O': raise - tm.assert_almost_equal(targ.real, res.real, + tm.assert_almost_equal(np.real(targ), np.real(res), check_dtype=check_dtype) - tm.assert_almost_equal(targ.imag, res.imag, + tm.assert_almost_equal(np.imag(targ), np.imag(res), check_dtype=check_dtype) def check_fun_data(self, testfunc, targfunc, testarval, targarval, From d5e619d8de3b491c6a78615f2687febff520b55f Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:36:51 -0500 Subject: [PATCH 3/9] filterwarning in a test --- pandas/tests/series/test_dtypes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 0d0cee79fcf5a..1c1e75ef2f7cc 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -428,6 +428,7 @@ def test_astype_empty_constructor_equality(self, dtype): as_type_empty = Series([]).astype(dtype) tm.assert_series_equal(init_empty, as_type_empty) + @pytest.mark.filterwarnings('ignore::DeprecationWarning') def test_complex(self): # see gh-4819: complex access for ndarray compat a = np.arange(5, dtype=np.float64) From 9c9dfae61121462e9d65d463d4d7e48ab380e643 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:38:22 -0500 Subject: [PATCH 4/9] add whatsnew for real and imag --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 8220f8979ee86..c7a86e6c45670 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -605,7 +605,7 @@ Other deprecations Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`). - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) - :attr:`Index.dtype_str` is deprecated. (:issue:``) -- +- :attr:`Series.imag` and :attr:`Series.real` is deprecated. (:issue:``) .. _whatsnew_0250.prior_deprecations: From f96f415dc078d70d399563c51ba3c9d9786146d6 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:46:28 -0500 Subject: [PATCH 5/9] Deprecate Series.put --- doc/source/whatsnew/v0.25.0.rst | 1 + pandas/core/series.py | 4 ++++ pandas/tests/series/test_internals.py | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c7a86e6c45670..b7847865e97c9 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -606,6 +606,7 @@ Other deprecations - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) - :attr:`Index.dtype_str` is deprecated. (:issue:``) - :attr:`Series.imag` and :attr:`Series.real` is deprecated. (:issue:``) +- :meth:`Series.put` is deprecated. (:issue:``) .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/series.py b/pandas/core/series.py index 813dc21148ec6..a6827349f33f9 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -617,10 +617,14 @@ def put(self, *args, **kwargs): """ Apply the `put` method to its `values` attribute if it has one. + .. deprecated:: 0.23.0 + See Also -------- numpy.ndarray.put """ + warnings.warn('`put` has been deprecated and will be removed in a' + 'future release.', DeprecationWarning, stacklevel=2) self._values.put(*args, **kwargs) def __len__(self): diff --git a/pandas/tests/series/test_internals.py b/pandas/tests/series/test_internals.py index 29846f10dae33..8eb1196d489f2 100644 --- a/pandas/tests/series/test_internals.py +++ b/pandas/tests/series/test_internals.py @@ -221,3 +221,9 @@ def test_hasnans_unchached_for_series(): ser.iloc[-1] = np.nan assert ser.hasnans is True assert Series.hasnans.__doc__ == pd.Index.hasnans.__doc__ + + +def test_put_deprecated(): + s = pd.Series([1]) + with tm.assert_produces_warning(DeprecationWarning): + s.put(0, 0) \ No newline at end of file From bef6fdde9c4a9b96add51a040dbc5fd4767f995c Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:50:17 -0500 Subject: [PATCH 6/9] Add issue numbers --- doc/source/whatsnew/v0.25.0.rst | 6 +++--- pandas/core/series.py | 4 ++-- pandas/tests/series/test_dtypes.py | 1 + pandas/tests/series/test_internals.py | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index b7847865e97c9..d41a2bf567fd2 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -604,9 +604,9 @@ Other deprecations - The :meth:`Series.ftype`, :meth:`Series.ftypes` and :meth:`DataFrame.ftypes` methods are deprecated and will be removed in a future version. Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`). - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) -- :attr:`Index.dtype_str` is deprecated. (:issue:``) -- :attr:`Series.imag` and :attr:`Series.real` is deprecated. (:issue:``) -- :meth:`Series.put` is deprecated. (:issue:``) +- :attr:`Index.dtype_str` is deprecated. (:issue:`18262`) +- :attr:`Series.imag` and :attr:`Series.real` is deprecated. (:issue:`18262`) +- :meth:`Series.put` is deprecated. (:issue:`18262`) .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/series.py b/pandas/core/series.py index a6827349f33f9..c06df250eecfc 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -617,14 +617,14 @@ def put(self, *args, **kwargs): """ Apply the `put` method to its `values` attribute if it has one. - .. deprecated:: 0.23.0 + .. deprecated:: 0.25.0 See Also -------- numpy.ndarray.put """ warnings.warn('`put` has been deprecated and will be removed in a' - 'future release.', DeprecationWarning, stacklevel=2) + 'future version.', DeprecationWarning, stacklevel=2) self._values.put(*args, **kwargs) def __len__(self): diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 1c1e75ef2f7cc..8b8f4fe136219 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -442,6 +442,7 @@ def test_complex(self): tm.assert_numpy_array_equal(4 * a, np.imag(b)) def test_real_imag_deprecated(self): + # GH 18262 s = pd.Series([1]) with tm.assert_produces_warning(DeprecationWarning): s.imag diff --git a/pandas/tests/series/test_internals.py b/pandas/tests/series/test_internals.py index 8eb1196d489f2..d9d847e20c1aa 100644 --- a/pandas/tests/series/test_internals.py +++ b/pandas/tests/series/test_internals.py @@ -224,6 +224,7 @@ def test_hasnans_unchached_for_series(): def test_put_deprecated(): + # GH 18262 s = pd.Series([1]) with tm.assert_produces_warning(DeprecationWarning): s.put(0, 0) \ No newline at end of file From 9e405a55b94361adbbc98d469e9034d2e3f8f859 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:51:57 -0500 Subject: [PATCH 7/9] Add newline at end of file --- pandas/tests/series/test_internals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_internals.py b/pandas/tests/series/test_internals.py index d9d847e20c1aa..9a6a5af44d6f7 100644 --- a/pandas/tests/series/test_internals.py +++ b/pandas/tests/series/test_internals.py @@ -227,4 +227,4 @@ def test_put_deprecated(): # GH 18262 s = pd.Series([1]) with tm.assert_produces_warning(DeprecationWarning): - s.put(0, 0) \ No newline at end of file + s.put(0, 0) From 0ebd68b80ffa98a2c28072dc6a8efac6cdbb0362 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 14:58:45 -0500 Subject: [PATCH 8/9] Use FutureWarning instead, grammar --- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/core/indexes/base.py | 2 +- pandas/core/series.py | 6 +++--- pandas/tests/indexes/multi/test_format.py | 2 +- pandas/tests/indexes/period/test_period.py | 4 ++-- pandas/tests/indexes/test_common.py | 2 +- pandas/tests/series/test_dtypes.py | 4 ++-- pandas/tests/series/test_internals.py | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index d41a2bf567fd2..2277becec0236 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -605,7 +605,7 @@ Other deprecations Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`). - :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`) - :attr:`Index.dtype_str` is deprecated. (:issue:`18262`) -- :attr:`Series.imag` and :attr:`Series.real` is deprecated. (:issue:`18262`) +- :attr:`Series.imag` and :attr:`Series.real` are deprecated. (:issue:`18262`) - :meth:`Series.put` is deprecated. (:issue:`18262`) .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 9a1019cfb6897..d25a4333ba62d 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -694,7 +694,7 @@ def dtype_str(self): .. deprecated:: 0.25.0 """ warnings.warn('`dtype_str` has been deprecated. Call `str` on the ' - 'dtype attribute instead.', DeprecationWarning, + 'dtype attribute instead.', FutureWarning, stacklevel=2) return str(self.dtype) diff --git a/pandas/core/series.py b/pandas/core/series.py index c06df250eecfc..31cb7432b3ae1 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -624,7 +624,7 @@ def put(self, *args, **kwargs): numpy.ndarray.put """ warnings.warn('`put` has been deprecated and will be removed in a' - 'future version.', DeprecationWarning, stacklevel=2) + 'future version.', FutureWarning, stacklevel=2) self._values.put(*args, **kwargs) def __len__(self): @@ -801,7 +801,7 @@ def real(self): .. deprecated 0.25.0 """ warnings.warn("`real` has be deprecated and will be removed in a " - "future verison", DeprecationWarning, stacklevel=2) + "future verison", FutureWarning, stacklevel=2) return self.values.real @real.setter @@ -816,7 +816,7 @@ def imag(self): .. deprecated 0.25.0 """ warnings.warn("`imag` has be deprecated and will be removed in a " - "future verison", DeprecationWarning, stacklevel=2) + "future verison", FutureWarning, stacklevel=2) return self.values.imag @imag.setter diff --git a/pandas/tests/indexes/multi/test_format.py b/pandas/tests/indexes/multi/test_format.py index 312ebf2a5d973..85d30b8f6de6b 100644 --- a/pandas/tests/indexes/multi/test_format.py +++ b/pandas/tests/indexes/multi/test_format.py @@ -8,7 +8,7 @@ def test_dtype_str(indices): - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): dtype = indices.dtype_str assert isinstance(dtype, str) assert dtype == str(indices.dtype) diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index 681497cfe2706..a70f67557bfc2 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -132,11 +132,11 @@ def test_shallow_copy_changing_freq_raises(self): def test_dtype_str(self): pi = pd.PeriodIndex([], freq='M') - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): assert pi.dtype_str == 'period[M]' assert pi.dtype_str == str(pi.dtype) - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): pi = pd.PeriodIndex([], freq='3M') assert pi.dtype_str == 'period[3M]' assert pi.dtype_str == str(pi.dtype) diff --git a/pandas/tests/indexes/test_common.py b/pandas/tests/indexes/test_common.py index c60b31e06f643..3cb907c6f5844 100644 --- a/pandas/tests/indexes/test_common.py +++ b/pandas/tests/indexes/test_common.py @@ -155,7 +155,7 @@ def test_set_name_methods(self, indices): assert indices.names == [name] def test_dtype_str(self, indices): - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): dtype = indices.dtype_str assert isinstance(dtype, str) assert dtype == str(indices.dtype) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 8b8f4fe136219..b9146534d10f1 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -428,7 +428,7 @@ def test_astype_empty_constructor_equality(self, dtype): as_type_empty = Series([]).astype(dtype) tm.assert_series_equal(init_empty, as_type_empty) - @pytest.mark.filterwarnings('ignore::DeprecationWarning') + @pytest.mark.filterwarnings('ignore::FutureWarning') def test_complex(self): # see gh-4819: complex access for ndarray compat a = np.arange(5, dtype=np.float64) @@ -444,7 +444,7 @@ def test_complex(self): def test_real_imag_deprecated(self): # GH 18262 s = pd.Series([1]) - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): s.imag s.real diff --git a/pandas/tests/series/test_internals.py b/pandas/tests/series/test_internals.py index 9a6a5af44d6f7..0b62624ad2696 100644 --- a/pandas/tests/series/test_internals.py +++ b/pandas/tests/series/test_internals.py @@ -226,5 +226,5 @@ def test_hasnans_unchached_for_series(): def test_put_deprecated(): # GH 18262 s = pd.Series([1]) - with tm.assert_produces_warning(DeprecationWarning): + with tm.assert_produces_warning(FutureWarning): s.put(0, 0) From bc2feda7b1007be7e001f30c173ab45c1272cf1f Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 28 Jun 2019 16:41:39 -0500 Subject: [PATCH 9/9] Remove one usage of dtype_str --- pandas/core/arrays/categorical.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 9f5e3e8ee77f0..a1d591458fba3 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1989,9 +1989,7 @@ def _repr_categories_info(self): """ category_strs = self._repr_categories() - dtype = getattr(self.categories, 'dtype_str', - str(self.categories.dtype)) - + dtype = str(self.categories.dtype) levheader = "Categories ({length}, {dtype}): ".format( length=len(self.categories), dtype=dtype) width, height = get_terminal_size()