Skip to content

Commit 710e4d5

Browse files
committed
changes for pre-commit.ci
1 parent eb2f210 commit 710e4d5

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

pandas/tests/indexes/test_common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ def test_hasnans_isnans(self, index_flat):
442442
def test_sort_values_invalid_na_position(index_with_missing, na_position):
443443
non_na_values = [x for x in index_with_missing if pd.notna(x)]
444444
if len({type(x) for x in non_na_values}) > 1:
445-
pytest.xfail("Sorting fails due to heterogeneous types in index (int vs str)")
445+
pytest.xfail("Sorting fails due to heterogeneous types in index"
446+
" (int vs str)")
446447

447448
with pytest.raises(ValueError, match=f"invalid na_position: {na_position}"):
448449
index_with_missing.sort_values(na_position=na_position)
@@ -456,7 +457,8 @@ def test_sort_values_with_missing(index_with_missing, na_position, request):
456457

457458
non_na_values = [x for x in index_with_missing if pd.notna(x)]
458459
if len({type(x) for x in non_na_values}) > 1:
459-
pytest.xfail("Sorting fails due to heterogeneous types in index (int vs str)")
460+
pytest.xfail("Sorting fails due to heterogeneous types"
461+
" in index (int vs str)")
460462

461463
if isinstance(index_with_missing, CategoricalIndex):
462464
request.applymarker(

pandas/tests/indexes/test_numpy_compat.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ def test_numpy_ufuncs_reductions(index, func, request):
155155
# TODO: overlap with tests.series.test_ufunc.test_reductions
156156
if len(index) == 0:
157157
pytest.skip("Test doesn't make sense for empty index.")
158-
159-
if any(isinstance(x, str) for x in index) and any(isinstance(x, int) for x in index):
158+
has_str = any(isinstance(x, str) for x in index)
159+
has_int = any(isinstance(x, int) for x in index)
160+
if has_str and has_int:
160161
request.applymarker(
161-
pytest.mark.xfail(reason="Cannot compare mixed types (int and str) in ufunc reductions")
162+
pytest.mark.xfail(reason="Cannot compare mixed types (int and str)"
163+
" in ufunc reductions")
162164
)
163165

164166
if isinstance(index, CategoricalIndex) and index.dtype.ordered is False:

pandas/tests/indexes/test_setops.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def test_union_same_types(index):
7474
def test_union_different_types(index_flat, index_flat2, request):
7575
idx1 = index_flat
7676
idx2 = index_flat2
77-
78-
# Ειδική μεταχείριση για mixed-int-string
79-
if idx1.equals(pd.Index([0, "a", 1, "b", 2, "c"])) or idx2.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
77+
# mixed int string
78+
target_index = pd.Index([0, "a", 1, "b", 2, "c"])
79+
if idx1.equals(target_index) or idx2.equals(target_index):
8080
idx1 = idx1.astype(str)
8181
idx2 = idx2.astype(str)
8282

@@ -919,12 +919,16 @@ def test_symmetric_difference_mi(self, sort):
919919
index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)])
920920

921921
def has_mixed_types(level):
922-
return any(isinstance(x, str) for x in level) and any(isinstance(x, int) for x in level)
922+
return (
923+
any(isinstance(x, str) for x in level)
924+
and any(isinstance(x, int) for x in level)
925+
)
923926

924927
for idx in [index1, index2]:
925928
for lvl in range(idx.nlevels):
926929
if has_mixed_types(idx.get_level_values(lvl)):
927-
pytest.skip(f"Mixed types in MultiIndex level {lvl} are not orderable")
930+
pytest.skip(f"Mixed types in MultiIndex level {lvl}"
931+
" are not orderable")
928932

929933
result = index1.symmetric_difference(index2, sort=sort)
930934
expected = MultiIndex.from_tuples([("bar", 2), ("baz", 3), ("bar", 3)])

pandas/tests/test_algos.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def test_factorize_complex(self):
6464
tm.assert_numpy_array_equal(uniques, expected_uniques)
6565

6666
@pytest.mark.parametrize("index_or_series_obj",
67-
[
68-
[1, 2, 3],
69-
["a", "b", "c"],
70-
[0, "a", 1, "b", 2, "c"]
71-
])
67+
[
68+
[1, 2, 3],
69+
["a", "b", "c"],
70+
[0, "a", 1, "b", 2, "c"]
71+
])
7272
@pytest.mark.parametrize("sort", [True, False])
7373
def test_factorize(self, index_or_series_obj, sort):
7474
obj = Index(index_or_series_obj)
@@ -77,7 +77,8 @@ def test_factorize(self, index_or_series_obj, sort):
7777
pytest.skip("Skipping test for empty Index")
7878

7979
if obj.name == "mixed-int-string" or obj.name is None:
80-
pytest.skip("Skipping test for mixed-int-string due to unsupported comparison between str and int")
80+
pytest.skip("Skipping test for mixed-int-string due"
81+
" to unsupported comparison between str and int")
8182

8283

8384
result_codes, result_uniques = obj.factorize(sort=sort)

0 commit comments

Comments
 (0)