From 92218807fec028571dfdcce553151030e6942359 Mon Sep 17 00:00:00 2001 From: Miloni Atal <65722749+MiloniAtal@users.noreply.github.com> Date: Wed, 8 Jun 2022 22:01:20 +0530 Subject: [PATCH] TST: Added test for bug Reindexing pd.Float64Dtype() series gives runtime warnings when passed to np.log (#47087) * TST: For issue GH 47055 * Changes according to pre-commit * Made changes according to review --- pandas/tests/series/methods/test_reindex.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandas/tests/series/methods/test_reindex.py b/pandas/tests/series/methods/test_reindex.py index e0f1491f49485..b64c7bec6ea39 100644 --- a/pandas/tests/series/methods/test_reindex.py +++ b/pandas/tests/series/methods/test_reindex.py @@ -2,7 +2,9 @@ import pytest from pandas import ( + NA, Categorical, + Float64Dtype, Index, MultiIndex, NaT, @@ -408,3 +410,16 @@ def test_reindex_missing_category(): msg = r"Cannot setitem on a Categorical with a new category \(-1\)" with pytest.raises(TypeError, match=msg): ser.reindex([1, 2, 3, 4, 5], fill_value=-1) + + +def test_reindexing_with_float64_NA_log(): + # GH 47055 + s = Series([1.0, NA], dtype=Float64Dtype()) + s_reindex = s.reindex(range(3)) + result = s_reindex.values._data + expected = np.array([1, np.NaN, np.NaN]) + tm.assert_numpy_array_equal(result, expected) + with tm.assert_produces_warning(None): + result_log = np.log(s_reindex) + expected_log = Series([0, np.NaN, np.NaN], dtype=Float64Dtype()) + tm.assert_series_equal(result_log, expected_log)