From 80bd3e81733fa463be5394402b301e1da9ce1e6d Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 14:59:12 -0800 Subject: [PATCH 1/6] remove name from check_result --- pandas/tests/indexing/common.py | 11 ++----- pandas/tests/indexing/test_iloc.py | 19 ++--------- pandas/tests/indexing/test_loc.py | 53 ++++++++---------------------- 3 files changed, 18 insertions(+), 65 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index fea34f795bd03..ae298ca58f063 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -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)] @@ -178,7 +174,6 @@ def check_values(self, f, func, values=False): def check_result( self, - name, method1, key1, method2, @@ -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)) diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 7c1d8ddd14317..265db971201b5 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -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", @@ -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", @@ -196,7 +194,6 @@ def test_iloc_getitem_list_int(self): # list of ints self.check_result( - "list int", "iloc", [0, 1, 2], "ix", @@ -204,7 +201,6 @@ def test_iloc_getitem_list_int(self): typs=["ints", "uints"], ) self.check_result( - "list int", "iloc", [2], "ix", @@ -212,7 +208,6 @@ def test_iloc_getitem_list_int(self): typs=["ints", "uints"], ) self.check_result( - "list int", "iloc", [0, 1, 2], "indexer", @@ -224,7 +219,6 @@ 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", @@ -232,7 +226,6 @@ def test_iloc_getitem_list_int(self): typs=["ints", "uints"], ) self.check_result( - "array int", "iloc", np.array([2]), "ix", @@ -240,7 +233,6 @@ def test_iloc_getitem_list_int(self): typs=["ints", "uints"], ) self.check_result( - "array int", "iloc", np.array([0, 1, 2]), "indexer", @@ -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", @@ -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", @@ -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", @@ -343,7 +332,6 @@ def test_iloc_getitem_slice(self): # slices self.check_result( - "slice", "iloc", slice(1, 3), "ix", @@ -351,7 +339,6 @@ def test_iloc_getitem_slice(self): typs=["ints", "uints"], ) self.check_result( - "slice", "iloc", slice(1, 3), "indexer", diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 732914b3b8947..408dabb78cbf0 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -97,33 +97,32 @@ def test_loc_getitem_int(self): # int label self.check_result( - "int label", "loc", 2, "ix", 2, typs=["ints", "uints"], axes=0 + "loc", 2, "ix", 2, typs=["ints", "uints"], axes=0 ) self.check_result( - "int label", "loc", 3, "ix", 3, typs=["ints", "uints"], axes=1 + "loc", 3, "ix", 3, typs=["ints", "uints"], axes=1 ) self.check_result( - "int label", "loc", 2, "ix", 2, typs=["label"], fails=KeyError + "loc", 2, "ix", 2, typs=["label"], fails=KeyError ) def test_loc_getitem_label(self): # label - self.check_result("label", "loc", "c", "ix", "c", typs=["labels"], axes=0) - self.check_result("label", "loc", "null", "ix", "null", typs=["mixed"], axes=0) - self.check_result("label", "loc", 8, "ix", 8, typs=["mixed"], axes=0) + self.check_result("loc", "c", "ix", "c", typs=["labels"], axes=0) + self.check_result("loc", "null", "ix", "null", typs=["mixed"], axes=0) + self.check_result("loc", 8, "ix", 8, typs=["mixed"], axes=0) self.check_result( - "label", "loc", Timestamp("20130102"), "ix", 1, typs=["ts"], axes=0 + "loc", Timestamp("20130102"), "ix", 1, typs=["ts"], axes=0 ) self.check_result( - "label", "loc", "c", "ix", "c", typs=["empty"], fails=KeyError + "loc", "c", "ix", "c", typs=["empty"], fails=KeyError ) def test_loc_getitem_label_out_of_range(self): # out of range label self.check_result( - "label range", "loc", "f", "ix", @@ -132,10 +131,9 @@ def test_loc_getitem_label_out_of_range(self): fails=KeyError, ) self.check_result( - "label range", "loc", "f", "ix", "f", typs=["floats"], fails=KeyError + "loc", "f", "ix", "f", typs=["floats"], fails=KeyError ) self.check_result( - "label range", "loc", 20, "ix", @@ -144,20 +142,19 @@ def test_loc_getitem_label_out_of_range(self): fails=KeyError, ) self.check_result( - "label range", "loc", 20, "ix", 20, typs=["labels"], fails=TypeError + "loc", 20, "ix", 20, typs=["labels"], fails=TypeError ) self.check_result( - "label range", "loc", 20, "ix", 20, typs=["ts"], axes=0, fails=TypeError + "loc", 20, "ix", 20, typs=["ts"], axes=0, fails=TypeError ) self.check_result( - "label range", "loc", 20, "ix", 20, typs=["floats"], axes=0, fails=KeyError + "loc", 20, "ix", 20, typs=["floats"], axes=0, fails=KeyError ) def test_loc_getitem_label_list(self): # list of labels self.check_result( - "list lbl", "loc", [0, 2, 4], "ix", @@ -166,7 +163,6 @@ def test_loc_getitem_label_list(self): axes=0, ) self.check_result( - "list lbl", "loc", [3, 6, 9], "ix", @@ -175,7 +171,6 @@ def test_loc_getitem_label_list(self): axes=1, ) self.check_result( - "list lbl", "loc", ["a", "b", "d"], "ix", @@ -184,7 +179,6 @@ def test_loc_getitem_label_list(self): axes=0, ) self.check_result( - "list lbl", "loc", ["A", "B", "C"], "ix", @@ -193,7 +187,6 @@ def test_loc_getitem_label_list(self): axes=1, ) self.check_result( - "list lbl", "loc", [2, 8, "null"], "ix", @@ -202,7 +195,6 @@ def test_loc_getitem_label_list(self): axes=0, ) self.check_result( - "list lbl", "loc", [Timestamp("20130102"), Timestamp("20130103")], "ix", @@ -213,7 +205,6 @@ def test_loc_getitem_label_list(self): def test_loc_getitem_label_list_with_missing(self): self.check_result( - "list lbl", "loc", [0, 1, 2], "indexer", @@ -223,7 +214,6 @@ def test_loc_getitem_label_list_with_missing(self): ) with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): self.check_result( - "list lbl", "loc", [0, 2, 10], "ix", @@ -235,7 +225,6 @@ def test_loc_getitem_label_list_with_missing(self): with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): self.check_result( - "list lbl", "loc", [3, 6, 7], "ix", @@ -248,7 +237,6 @@ def test_loc_getitem_label_list_with_missing(self): # GH 17758 - MultiIndex and missing keys with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): self.check_result( - "list lbl", "loc", [(1, 3), (1, 4), (2, 5)], "ix", @@ -271,7 +259,6 @@ def test_getitem_label_list_with_missing(self): def test_loc_getitem_label_list_fails(self): # fails self.check_result( - "list lbl", "loc", [20, 30, 40], "ix", @@ -284,7 +271,6 @@ def test_loc_getitem_label_list_fails(self): def test_loc_getitem_label_array_like(self): # array like self.check_result( - "array like", "loc", Series(index=[0, 2, 4]).index, "ix", @@ -293,7 +279,6 @@ def test_loc_getitem_label_array_like(self): axes=0, ) self.check_result( - "array like", "loc", Series(index=[3, 6, 9]).index, "ix", @@ -306,14 +291,13 @@ def test_loc_getitem_bool(self): # boolean indexers b = [True, False, True, False] self.check_result( - "bool", "loc", b, "ix", b, typs=["ints", "uints", "labels", "mixed", "ts", "floats"], ) - self.check_result("bool", "loc", b, "ix", b, typs=["empty"], fails=IndexError) + self.check_result("loc", b, "ix", b, typs=["empty"], fails=IndexError) @pytest.mark.parametrize("index", [[True, False], [True, False, True, False]]) def test_loc_getitem_bool_diff_len(self, index): @@ -329,7 +313,6 @@ def test_loc_getitem_int_slice(self): # ok self.check_result( - "int slice2", "loc", slice(2, 4), "ix", @@ -338,7 +321,6 @@ def test_loc_getitem_int_slice(self): axes=0, ) self.check_result( - "int slice2", "loc", slice(3, 6), "ix", @@ -444,7 +426,6 @@ def test_loc_getitem_label_slice(self): # label slices (with ints) self.check_result( - "lab slice", "loc", slice(1, 3), "ix", @@ -455,7 +436,6 @@ def test_loc_getitem_label_slice(self): # real label slices self.check_result( - "lab slice", "loc", slice("a", "c"), "ix", @@ -464,7 +444,6 @@ def test_loc_getitem_label_slice(self): axes=0, ) self.check_result( - "lab slice", "loc", slice("A", "C"), "ix", @@ -474,7 +453,6 @@ def test_loc_getitem_label_slice(self): ) self.check_result( - "ts slice", "loc", slice("20130102", "20130104"), "ix", @@ -483,7 +461,6 @@ def test_loc_getitem_label_slice(self): axes=0, ) self.check_result( - "ts slice", "loc", slice("20130102", "20130104"), "ix", @@ -495,7 +472,6 @@ def test_loc_getitem_label_slice(self): # GH 14316 self.check_result( - "ts slice rev", "loc", slice("20130104", "20130102"), "indexer", @@ -505,7 +481,6 @@ def test_loc_getitem_label_slice(self): ) self.check_result( - "mixed slice", "loc", slice(2, 8), "ix", @@ -515,7 +490,6 @@ def test_loc_getitem_label_slice(self): fails=TypeError, ) self.check_result( - "mixed slice", "loc", slice(2, 8), "ix", @@ -526,7 +500,6 @@ def test_loc_getitem_label_slice(self): ) self.check_result( - "mixed slice", "loc", slice(2, 4, 2), "ix", From 2aed36fa9e5a376742720b41e5e00bf4d086fdfd Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 15:04:30 -0800 Subject: [PATCH 2/6] CLN: remove kinds kwarg --- pandas/tests/indexing/common.py | 8 +------- pandas/tests/indexing/test_iloc.py | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index ae298ca58f063..22cc91e959690 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -179,7 +179,6 @@ def check_result( method2, key2, typs=None, - kinds=None, axes=None, fails=None, ): @@ -249,9 +248,6 @@ def _print(result, error=None): if typs is None: typs = self._typs - if kinds is None: - kinds = self._kinds - if axes is None: axes = [0, 1] elif not isinstance(axes, (tuple, list)): @@ -259,9 +255,7 @@ def _print(result, error=None): axes = [axes] # check - for kind in kinds: - if kind not in self._kinds: - continue + for kind in self._kinds: d = getattr(self, kind) for ax in axes: diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 265db971201b5..233dfd0b94619 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -275,7 +275,6 @@ def test_iloc_getitem_dups(self): [0, 1, 1, 3], "ix", {0: [0, 2, 2, 6], 1: [0, 3, 3, 9]}, - kinds=["series", "frame"], typs=["ints", "uints"], ) From 9dcc2ac37167ddeed1fd4e3a90fce5c57aa32322 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 15:29:13 -0800 Subject: [PATCH 3/6] remove _print method --- pandas/tests/indexing/common.py | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index 22cc91e959690..55feb5c5c3289 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -173,28 +173,13 @@ def check_values(self, f, func, values=False): tm.assert_almost_equal(result, expected) def check_result( - self, - method1, - key1, - method2, - key2, - typs=None, - axes=None, - fails=None, + self, method1, key1, method2, key2, typs=None, axes=None, fails=None, ): - def _eq(typ, kind, axis, obj, key1, key2): + def _eq(axis, obj, key1, key2): """ compare equal for these 2 keys """ if axis > obj.ndim - 1: return - def _print(result, error=None): - err = str(error) if error is not None else "" - msg = ( - "[%-16.16s]: [typ->%-8.8s,obj->%-8.8s," - "key1->(%-4.4s),key2->(%-4.4s),axis->%s] %s" - % (result, typ, kind, method1, method2, axis, err) - ) - try: rs = getattr(obj, method1).__getitem__(_axify(obj, key1, axis)) @@ -207,7 +192,6 @@ def _print(result, error=None): except (KeyError, IndexError): # TODO: why is this allowed? result = "no comp" - _print(result) return detail = None @@ -227,23 +211,19 @@ def _print(result, error=None): if result == "fail": result = "ok (fail)" - _print(result) if not result.startswith("ok"): raise AssertionError(detail) - except AssertionError: - raise except (IndexError, TypeError, KeyError) as detail: # if we are in fails, the ok, otherwise raise it if fails is not None: if isinstance(detail, fails): - result = "ok ({0.__name__})".format(type(detail)) - _print(result) + result = f"ok ({type(detail).__name__})" return result = type(detail).__name__ - raise AssertionError(_print(result, error=detail)) + raise AssertionError(result, detail) if typs is None: typs = self._typs @@ -264,4 +244,4 @@ def _print(result, error=None): continue obj = d[typ] - _eq(typ=typ, kind=kind, axis=ax, obj=obj, key1=key1, key2=key2) + _eq(axis=ax, obj=obj, key1=key1, key2=key2) From 29e5123c07609c6918fb8c0707e962200eba373f Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 15:32:45 -0800 Subject: [PATCH 4/6] remove unnecessary catch --- pandas/tests/indexing/common.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index 55feb5c5c3289..4eb57c739b93b 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -196,15 +196,11 @@ def _eq(axis, obj, key1, key2): detail = None - try: - if is_scalar(rs) and is_scalar(xp): - assert rs == xp - else: - tm.assert_equal(rs, xp) - result = "ok" - except AssertionError as exc: - detail = str(exc) - result = "fail" + if is_scalar(rs) and is_scalar(xp): + assert rs == xp + else: + tm.assert_equal(rs, xp) + result = "ok" # reverse the checks if fails is True: From 8e9ad747ae9ed15459cc98ab45ebee02416cd781 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 15:33:52 -0800 Subject: [PATCH 5/6] CLN: remove unreachable bracnhes --- pandas/tests/indexing/common.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index 4eb57c739b93b..4842d1c45f897 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -200,15 +200,6 @@ def _eq(axis, obj, key1, key2): assert rs == xp else: tm.assert_equal(rs, xp) - result = "ok" - - # reverse the checks - if fails is True: - if result == "fail": - result = "ok (fail)" - - if not result.startswith("ok"): - raise AssertionError(detail) except (IndexError, TypeError, KeyError) as detail: From 27de19cc78300ecba4a39f1353c749be96718fd7 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 25 Nov 2019 20:22:25 -0800 Subject: [PATCH 6/6] lint --- pandas/tests/indexing/common.py | 2 - pandas/tests/indexing/test_iloc.py | 14 +--- pandas/tests/indexing/test_loc.py | 113 +++++------------------------ 3 files changed, 23 insertions(+), 106 deletions(-) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index 4842d1c45f897..db6dddfdca11b 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -194,8 +194,6 @@ def _eq(axis, obj, key1, key2): result = "no comp" return - detail = None - if is_scalar(rs) and is_scalar(xp): assert rs == xp else: diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 233dfd0b94619..d826d89f85ef5 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -137,9 +137,7 @@ def test_iloc_non_integer_raises(self, index, columns, index_vals, column_vals): def test_iloc_getitem_int(self): # integer - self.check_result( - "iloc", 2, "ix", {0: 4, 1: 6, 2: 8}, typs=["ints", "uints"] - ) + self.check_result("iloc", 2, "ix", {0: 4, 1: 6, 2: 8}, typs=["ints", "uints"]) self.check_result( "iloc", 2, @@ -152,9 +150,7 @@ def test_iloc_getitem_int(self): def test_iloc_getitem_neg_int(self): # neg integer - self.check_result( - "iloc", -1, "ix", {0: 6, 1: 9, 2: 12}, typs=["ints", "uints"] - ) + self.check_result("iloc", -1, "ix", {0: 6, 1: 9, 2: 12}, typs=["ints", "uints"]) self.check_result( "iloc", -1, @@ -201,11 +197,7 @@ def test_iloc_getitem_list_int(self): typs=["ints", "uints"], ) self.check_result( - "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( "iloc", diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 408dabb78cbf0..d3af3f6322ef2 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -96,15 +96,9 @@ def test_loc_setitem_slice(self): def test_loc_getitem_int(self): # int label - self.check_result( - "loc", 2, "ix", 2, typs=["ints", "uints"], axes=0 - ) - self.check_result( - "loc", 3, "ix", 3, typs=["ints", "uints"], axes=1 - ) - self.check_result( - "loc", 2, "ix", 2, typs=["label"], fails=KeyError - ) + self.check_result("loc", 2, "ix", 2, typs=["ints", "uints"], axes=0) + self.check_result("loc", 3, "ix", 3, typs=["ints", "uints"], axes=1) + self.check_result("loc", 2, "ix", 2, typs=["label"], fails=KeyError) def test_loc_getitem_label(self): @@ -112,12 +106,8 @@ def test_loc_getitem_label(self): self.check_result("loc", "c", "ix", "c", typs=["labels"], axes=0) self.check_result("loc", "null", "ix", "null", typs=["mixed"], axes=0) self.check_result("loc", 8, "ix", 8, typs=["mixed"], axes=0) - self.check_result( - "loc", Timestamp("20130102"), "ix", 1, typs=["ts"], axes=0 - ) - self.check_result( - "loc", "c", "ix", "c", typs=["empty"], fails=KeyError - ) + self.check_result("loc", Timestamp("20130102"), "ix", 1, typs=["ts"], axes=0) + self.check_result("loc", "c", "ix", "c", typs=["empty"], fails=KeyError) def test_loc_getitem_label_out_of_range(self): @@ -130,69 +120,31 @@ def test_loc_getitem_label_out_of_range(self): typs=["ints", "uints", "labels", "mixed", "ts"], fails=KeyError, ) + self.check_result("loc", "f", "ix", "f", typs=["floats"], fails=KeyError) self.check_result( - "loc", "f", "ix", "f", typs=["floats"], fails=KeyError - ) - self.check_result( - "loc", - 20, - "ix", - 20, - typs=["ints", "uints", "mixed"], - fails=KeyError, - ) - self.check_result( - "loc", 20, "ix", 20, typs=["labels"], fails=TypeError - ) - self.check_result( - "loc", 20, "ix", 20, typs=["ts"], axes=0, fails=TypeError - ) - self.check_result( - "loc", 20, "ix", 20, typs=["floats"], axes=0, fails=KeyError + "loc", 20, "ix", 20, typs=["ints", "uints", "mixed"], fails=KeyError, ) + self.check_result("loc", 20, "ix", 20, typs=["labels"], fails=TypeError) + self.check_result("loc", 20, "ix", 20, typs=["ts"], axes=0, fails=TypeError) + self.check_result("loc", 20, "ix", 20, typs=["floats"], axes=0, fails=KeyError) def test_loc_getitem_label_list(self): # list of labels self.check_result( - "loc", - [0, 2, 4], - "ix", - [0, 2, 4], - typs=["ints", "uints"], - axes=0, + "loc", [0, 2, 4], "ix", [0, 2, 4], typs=["ints", "uints"], axes=0, ) self.check_result( - "loc", - [3, 6, 9], - "ix", - [3, 6, 9], - typs=["ints", "uints"], - axes=1, + "loc", [3, 6, 9], "ix", [3, 6, 9], typs=["ints", "uints"], axes=1, ) self.check_result( - "loc", - ["a", "b", "d"], - "ix", - ["a", "b", "d"], - typs=["labels"], - axes=0, + "loc", ["a", "b", "d"], "ix", ["a", "b", "d"], typs=["labels"], axes=0, ) self.check_result( - "loc", - ["A", "B", "C"], - "ix", - ["A", "B", "C"], - typs=["labels"], - axes=1, + "loc", ["A", "B", "C"], "ix", ["A", "B", "C"], typs=["labels"], axes=1, ) self.check_result( - "loc", - [2, 8, "null"], - "ix", - [2, 8, "null"], - typs=["mixed"], - axes=0, + "loc", [2, 8, "null"], "ix", [2, 8, "null"], typs=["mixed"], axes=0, ) self.check_result( "loc", @@ -205,12 +157,7 @@ def test_loc_getitem_label_list(self): def test_loc_getitem_label_list_with_missing(self): self.check_result( - "loc", - [0, 1, 2], - "indexer", - [0, 1, 2], - typs=["empty"], - fails=KeyError, + "loc", [0, 1, 2], "indexer", [0, 1, 2], typs=["empty"], fails=KeyError, ) with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): self.check_result( @@ -313,20 +260,10 @@ def test_loc_getitem_int_slice(self): # ok self.check_result( - "loc", - slice(2, 4), - "ix", - [2, 4], - typs=["ints", "uints"], - axes=0, + "loc", slice(2, 4), "ix", [2, 4], typs=["ints", "uints"], axes=0, ) self.check_result( - "loc", - slice(3, 6), - "ix", - [3, 6], - typs=["ints", "uints"], - axes=1, + "loc", slice(3, 6), "ix", [3, 6], typs=["ints", "uints"], axes=1, ) def test_loc_to_fail(self): @@ -436,20 +373,10 @@ def test_loc_getitem_label_slice(self): # real label slices self.check_result( - "loc", - slice("a", "c"), - "ix", - slice("a", "c"), - typs=["labels"], - axes=0, + "loc", slice("a", "c"), "ix", slice("a", "c"), typs=["labels"], axes=0, ) self.check_result( - "loc", - slice("A", "C"), - "ix", - slice("A", "C"), - typs=["labels"], - axes=1, + "loc", slice("A", "C"), "ix", slice("A", "C"), typs=["labels"], axes=1, ) self.check_result(