From 1e202adf4d0f46810e629a5defdd397e4a3ea636 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 25 Oct 2020 18:56:02 -0700 Subject: [PATCH] TST/REF: misplaced tests in tests.base --- pandas/tests/base/test_drop_duplicates.py | 11 ++++++----- pandas/tests/base/test_misc.py | 8 -------- pandas/tests/indexes/base_class/test_indexing.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pandas/tests/base/test_drop_duplicates.py b/pandas/tests/base/test_drop_duplicates.py index 4032890b4db18..8cde7aae5df05 100644 --- a/pandas/tests/base/test_drop_duplicates.py +++ b/pandas/tests/base/test_drop_duplicates.py @@ -1,12 +1,14 @@ from datetime import datetime import numpy as np +import pytest import pandas as pd import pandas._testing as tm -def test_drop_duplicates_series_vs_dataframe(): +@pytest.mark.parametrize("keep", ["first", "last", False]) +def test_drop_duplicates_series_vs_dataframe(keep): # GH 14192 df = pd.DataFrame( { @@ -24,7 +26,6 @@ def test_drop_duplicates_series_vs_dataframe(): } ) for column in df.columns: - for keep in ["first", "last", False]: - dropped_frame = df[[column]].drop_duplicates(keep=keep) - dropped_series = df[column].drop_duplicates(keep=keep) - tm.assert_frame_equal(dropped_frame, dropped_series.to_frame()) + dropped_frame = df[[column]].drop_duplicates(keep=keep) + dropped_series = df[column].drop_duplicates(keep=keep) + tm.assert_frame_equal(dropped_frame, dropped_series.to_frame()) diff --git a/pandas/tests/base/test_misc.py b/pandas/tests/base/test_misc.py index f7952c81cfd61..2a17006a7c407 100644 --- a/pandas/tests/base/test_misc.py +++ b/pandas/tests/base/test_misc.py @@ -14,7 +14,6 @@ import pandas as pd from pandas import DataFrame, Index, IntervalIndex, Series -import pandas._testing as tm @pytest.mark.parametrize( @@ -196,10 +195,3 @@ def test_access_by_position(index): msg = "single positional indexer is out-of-bounds" with pytest.raises(IndexError, match=msg): series.iloc[size] - - -def test_get_indexer_non_unique_dtype_mismatch(): - # GH 25459 - indexes, missing = Index(["A", "B"]).get_indexer_non_unique(Index([0])) - tm.assert_numpy_array_equal(np.array([-1], dtype=np.intp), indexes) - tm.assert_numpy_array_equal(np.array([0], dtype=np.intp), missing) diff --git a/pandas/tests/indexes/base_class/test_indexing.py b/pandas/tests/indexes/base_class/test_indexing.py index b2fa8f31ee5ec..fd04a820037b9 100644 --- a/pandas/tests/indexes/base_class/test_indexing.py +++ b/pandas/tests/indexes/base_class/test_indexing.py @@ -1,6 +1,8 @@ +import numpy as np import pytest from pandas import Index +import pandas._testing as tm class TestGetSliceBounds: @@ -24,3 +26,11 @@ def test_get_slice_bounds_outside(self, kind, side, expected, data, bound): def test_get_slice_bounds_invalid_side(self): with pytest.raises(ValueError, match="Invalid value for side kwarg"): Index([]).get_slice_bound("a", kind=None, side="middle") + + +class TestGetIndexerNonUnique: + def test_get_indexer_non_unique_dtype_mismatch(self): + # GH#25459 + indexes, missing = Index(["A", "B"]).get_indexer_non_unique(Index([0])) + tm.assert_numpy_array_equal(np.array([-1], dtype=np.intp), indexes) + tm.assert_numpy_array_equal(np.array([0], dtype=np.intp), missing)