Skip to content

Commit 079aeb1

Browse files
committed
pre-commit run --all-files changes
1 parent 710e4d5 commit 079aeb1

File tree

8 files changed

+29
-32
lines changed

8 files changed

+29
-32
lines changed

pandas/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def _create_mi_with_dt64tz_level():
706706
"string-python": Index(
707707
pd.array([f"pandas_{i}" for i in range(10)], dtype="string[python]")
708708
),
709-
"mixed-int-string": Index([0, "a", 1, "b", 2, "c"])
709+
"mixed-int-string": Index([0, "a", 1, "b", 2, "c"]),
710710
}
711711
if has_pyarrow:
712712
idx = Index(pd.array([f"pandas_{i}" for i in range(10)], dtype="string[pyarrow]"))

pandas/tests/base/test_value_counts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ def test_value_counts_null(null_obj, index_or_series_obj):
6363
elif isinstance(orig, MultiIndex):
6464
pytest.skip(f"MultiIndex can't hold '{null_obj}'")
6565

66-
if obj.dtype == 'object':
66+
if obj.dtype == "object":
6767
obj = obj.astype(str)
6868

69-
7069
values = obj._values
7170
values[0:2] = null_obj
7271

pandas/tests/indexes/test_common.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ 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"
446-
" (int vs str)")
445+
pytest.mark.xfail(reason="Sorting fails due to heterogeneous types in index (int vs str)")
447446

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

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

463461
if isinstance(index_with_missing, CategoricalIndex):
464462
request.applymarker(

pandas/tests/indexes/test_mixed_int_string.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pytest
2+
23
import pandas as pd
34

5+
46
def test_mixed_int_string_index():
57
idx = pd.Index([0, "a", 1, "b", 2, "c"])
68

pandas/tests/indexes/test_numpy_compat.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ def test_numpy_ufuncs_reductions(index, func, request):
159159
has_int = any(isinstance(x, int) for x in index)
160160
if has_str and has_int:
161161
request.applymarker(
162-
pytest.mark.xfail(reason="Cannot compare mixed types (int and str)"
163-
" in ufunc reductions")
162+
pytest.mark.xfail(
163+
reason="Cannot compare mixed types (int and str) in ufunc reductions"
164+
)
164165
)
165166

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

pandas/tests/indexes/test_old_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def test_argsort(self, index):
359359
pytest.skip(f"{type(self).__name__} separately tested")
360360

361361
# New test for mixed-int-string
362-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
362+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
363363
result = index.astype(str).argsort()
364364
expected = np.array(index.astype(str)).argsort()
365365
tm.assert_numpy_array_equal(result, expected, check_dtype=False)

pandas/tests/indexes/test_setops.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
from datetime import datetime
77
import operator
8-
import pandas as pd
8+
99
import numpy as np
1010
import pytest
1111

1212
from pandas._libs import lib
1313

1414
from pandas.core.dtypes.cast import find_common_type
1515

16+
import pandas as pd
1617
from pandas import (
1718
CategoricalDtype,
1819
CategoricalIndex,
@@ -64,13 +65,14 @@ def index_flat2(index_flat):
6465

6566
def test_union_same_types(index):
6667
# mixed int string
67-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
68+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
6869
index = index.astype(str)
6970

7071
idx1 = index.sort_values()
7172
idx2 = index.sort_values()
7273
assert idx1.union(idx2, sort=False).dtype == idx1.dtype
7374

75+
7476
def test_union_different_types(index_flat, index_flat2, request):
7577
idx1 = index_flat
7678
idx2 = index_flat2
@@ -129,6 +131,7 @@ def test_union_different_types(index_flat, index_flat2, request):
129131
assert res1.dtype == common_dtype
130132
assert res2.dtype == common_dtype
131133

134+
132135
@pytest.mark.parametrize(
133136
"idx1,idx2",
134137
[
@@ -233,7 +236,6 @@ def test_intersection_base(self, index):
233236

234237
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
235238
def test_union_base(self, index):
236-
237239
if index.inferred_type in ["mixed", "mixed-integer"]:
238240
pytest.skip("Mixed-type Index not orderable; union fails")
239241

@@ -295,7 +297,6 @@ def test_difference_base(self, sort, index):
295297

296298
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
297299
def test_symmetric_difference(self, index, using_infer_string, request):
298-
299300
if (
300301
using_infer_string
301302
and index.dtype == "object"
@@ -392,7 +393,7 @@ def test_union_unequal(self, index_flat, fname, sname, expected_name):
392393
else:
393394
index = index_flat
394395

395-
if index.dtype == 'object':
396+
if index.dtype == "object":
396397
index = index.astype(str)
397398

398399
# test copy.union(subset) - need sort for unicode and string
@@ -464,7 +465,7 @@ def test_intersect_unequal(self, index_flat, fname, sname, expected_name):
464465
else:
465466
index = index_flat
466467

467-
if index.dtype == 'object':
468+
if index.dtype == "object":
468469
index = index.astype(str)
469470
# test copy.intersection(subset) - need sort for unicode and string
470471
first = index.copy().set_names(fname)
@@ -919,16 +920,16 @@ def test_symmetric_difference_mi(self, sort):
919920
index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)])
920921

921922
def has_mixed_types(level):
922-
return (
923-
any(isinstance(x, str) for x in level)
924-
and any(isinstance(x, int) for x in level)
923+
return any(isinstance(x, str) for x in level) and any(
924+
isinstance(x, int) for x in level
925925
)
926926

927927
for idx in [index1, index2]:
928928
for lvl in range(idx.nlevels):
929929
if has_mixed_types(idx.get_level_values(lvl)):
930-
pytest.skip(f"Mixed types in MultiIndex level {lvl}"
931-
" are not orderable")
930+
pytest.skip(
931+
f"Mixed types in MultiIndex level {lvl} are not orderable"
932+
)
932933

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

pandas/tests/test_algos.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,9 @@ def test_factorize_complex(self):
6363
expected_uniques = np.array([(1 + 0j), (2 + 0j), (2 + 1j)], dtype=complex)
6464
tm.assert_numpy_array_equal(uniques, expected_uniques)
6565

66-
@pytest.mark.parametrize("index_or_series_obj",
67-
[
68-
[1, 2, 3],
69-
["a", "b", "c"],
70-
[0, "a", 1, "b", 2, "c"]
71-
])
66+
@pytest.mark.parametrize(
67+
"index_or_series_obj", [[1, 2, 3], ["a", "b", "c"], [0, "a", 1, "b", 2, "c"]]
68+
)
7269
@pytest.mark.parametrize("sort", [True, False])
7370
def test_factorize(self, index_or_series_obj, sort):
7471
obj = Index(index_or_series_obj)
@@ -77,9 +74,10 @@ def test_factorize(self, index_or_series_obj, sort):
7774
pytest.skip("Skipping test for empty Index")
7875

7976
if obj.name == "mixed-int-string" or obj.name is None:
80-
pytest.skip("Skipping test for mixed-int-string due"
81-
" to unsupported comparison between str and int")
82-
77+
pytest.skip(
78+
"Skipping test for mixed-int-string due "
79+
"to unsupported comparison between str and int"
80+
)
8381

8482
result_codes, result_uniques = obj.factorize(sort=sort)
8583

@@ -92,11 +90,9 @@ def test_factorize(self, index_or_series_obj, sort):
9290
if expected_uniques.dtype == bool and obj.dtype == object:
9391
expected_uniques = expected_uniques.astype(object)
9492

95-
9693
if sort:
9794
expected_uniques = expected_uniques.sort_values()
9895

99-
10096
# construct an integer ndarray so that
10197
# `expected_uniques.take(expected_codes)` is equal to `obj`
10298
expected_uniques_list = list(expected_uniques)

0 commit comments

Comments
 (0)