8000 CLN: trim unnecessary code in indexing tests by jbrockmendel · Pull Request #29845 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

CLN: trim unnecessary code in indexing tests #29845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 27, 2019
Merged
Next Next commit
remove name from check_result
  • Loading branch information
jbrockmendel committed Nov 25, 2019
commit 80bd3e81733fa463be5394402b301e1da9ce1e6d
11 changes: 2 additions & 9 deletions pandas/tests/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from pandas import DataFrame, Float64Index, MultiIndex, Series, UInt64Index, date_range
import pandas.util.testing as tm

from pandas.io.formats.printing import pprint_thing

_verbose = False


def _mklbl(prefix, n):
return ["{prefix}{i}".format(prefix=prefix, i=i) for i in range(n)]
Expand Down Expand Up @@ -178,7 +174,6 @@ def check_values(self, f, func, values=False):

def check_result(
self,
name,
method1,
key1,
method2,
Expand All @@ -196,12 +191,10 @@ def _eq(typ, kind, axis, obj, key1, key2):
def _print(result, error=None):
err = str(error) if error is not None else ""
msg = (
"%-16.16s [%-16.16s]: [typ->%-8.8s,obj->%-8.8s,"
"[%-16.16s]: [typ->%-8.8s,obj->%-8.8s,"
"key1->(%-4.4s),key2->(%-4.4s),axis->%s] %s"
% (name, result, typ, kind, method1, method2, axis, err)
% (result, typ, kind, method1, method2, axis, err)
)
if _verbose:
pprint_thing(msg)

try:
rs = getattr(obj, method1).__getitem__(_axify(obj, key1, axis))
Expand Down
19 changes: 3 additions & 16 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ def test_iloc_getitem_int(self):

# integer
self.check_result(
"integer", "iloc", 2, "ix", {0: 4, 1: 6, 2: 8}, typs=["ints", "uints"]
"iloc", 2, "ix", {0: 4, 1: 6, 2: 8}, typs=["ints", "uints"]
)
self.check_result(
"integer",
"iloc",
2,
"indexer",
Expand All @@ -154,10 +153,9 @@ def test_iloc_getitem_neg_int(self):

# neg integer
self.check_result(
"neg int", "iloc", -1, "ix", {0: 6, 1: 9, 2: 12}, typs=["ints", "uints"]
"iloc", -1, "ix", {0: 6, 1: 9, 2: 12}, typs=["ints", "uints"]
)
self.check_result(
"neg int",
"iloc",
-1,
"indexer",
Expand Down Expand Up @@ -196,23 +194,20 @@ def test_iloc_getitem_list_int(self):

# list of ints
self.check_result(
"list int",
"iloc",
[0, 1, 2],
"ix",
{0: [0, 2, 4], 1: [0, 3, 6], 2: [0, 4, 8]},
typs=["ints", "uints"],
)
self.check_result(
"list int",
"iloc",
[2],
"ix",
{0: [4], 1: [6], 2: [8]},
typs=[&qu 8000 ot;ints", "uints"],
)
self.check_result(
"list int",
"iloc",
[0, 1, 2],
"indexer",
Expand All @@ -224,23 +219,20 @@ def test_iloc_getitem_list_int(self):
# array of ints (GH5006), make sure that a single indexer is returning
# the correct type
self.check_result(
"array int",
"iloc",
np.array([0, 1, 2]),
"ix",
{0: [0, 2, 4], 1: [0, 3, 6], 2: [0, 4, 8]},
typs=["ints", "uints"],
)
self.check_result(
"array int",
"iloc",
np.array([2]),
"ix",
{0: [4], 1: [6], 2: [8]},
typs=["ints", "uints"],
)
self.check_result(
"array int",
"iloc",
np.array([0, 1, 2]),
"indexer",
Expand Down Expand Up @@ -279,7 +271,6 @@ def test_iloc_getitem_neg_int_can_reach_first_index(self):
def test_iloc_getitem_dups(self):

self.check_result(
"list int (dups)",
"iloc",
[0, 1, 1, 3],
"ix",
Expand All @@ -306,7 +297,6 @@ def test_iloc_getitem_array(self):
# array like
s = Series(index=range(1, 4))
self.check_result(
"array like",
"iloc",
s.index,
"ix",
Expand All @@ -318,9 +308,8 @@ def test_iloc_getitem_bool(self):

# boolean indexers
b = [True, False, True, False]
self.check_result("bool", "iloc", b, "ix", b, typs=["ints", "uints"])
self.check_result("iloc", b, "ix", b, typs=["ints", "uints"])
self.check_result(
"bool",
"iloc",
b,
"ix",
Expand All @@ -343,15 +332,13 @@ def test_iloc_getitem_slice(self):

# slices
self.check_result(
"slice",
"iloc",
slice(1, 3),
"ix",
{0: [2, 4], 1: [3, 6], 2: [4, 8]},
typs=["ints", "uints"],
)
self.check_result(
"slice",
"iloc",
slice(1, 3),
"indexer",
Expand Down
Loading
0