Skip to content

Commit 0b4045f

Browse files
committed
precommit check
1 parent 8d6f0e0 commit 0b4045f

8 files changed

+25
-27
lines changed

pandas/tests/base/test_value_counts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def test_value_counts_null(null_obj, index_or_series_obj):
6666
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/multi/test_setops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def test_union_with_duplicates_keep_ea_dtype(dupe_val, any_numeric_ea_dtype):
627627
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
628628
def test_union_duplicates(index, request):
629629
# special case for mixed types
630-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
630+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
631631
index = index.map(str)
632632

633633
# GH#38977

pandas/tests/indexes/test_common.py

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

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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ def test_numpy_ufuncs_reductions(index, func, request):
156156
if len(index) == 0:
157157
pytest.skip("Test doesn't make sense for empty index.")
158158

159-
if any(isinstance(x, str) for x in index) and \
160-
any(isinstance(x, int) for x in index):
159+
if any(isinstance(x, str) for x in index) and any(
160+
isinstance(x, int) for x in index
161+
):
161162
request.applymarker(
162163
pytest.mark.xfail(
163164
reason=(
164-
"Cannot compare mixed types (int and str) in ufunc reductions"
165-
" and should raise a TypeError"
165+
"Cannot compare mixed types (int and str) in ufunc reductions "
166+
"and should raise a TypeError"
166167
)
167168
)
168169
)

pandas/tests/indexes/test_old_base.py

Lines changed: 2 additions & 2 deletions
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)
@@ -371,7 +371,7 @@ def test_argsort(self, index):
371371

372372
def test_numpy_argsort(self, index):
373373
# new test for mixed-int-string
374-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
374+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
375375
result = np.argsort(index.astype(str))
376376
expected = index.astype(str).argsort()
377377
tm.assert_numpy_array_equal(result, expected)

pandas/tests/indexes/test_setops.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

@@ -64,20 +64,22 @@ def index_flat2(index_flat):
6464

6565
def test_union_same_types(index):
6666
# mixed int string
67-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
67+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
6868
index = index.astype(str)
6969

7070
idx1 = index.sort_values()
7171
idx2 = index.sort_values()
7272
assert idx1.union(idx2, sort=False).dtype == idx1.dtype
7373

74+
7475
def test_union_different_types(index_flat, index_flat2, request):
7576
idx1 = index_flat
7677
idx2 = index_flat2
7778

7879
# Special handling for mixed int-string types
79-
if idx1.equals(pd.Index([0, "a", 1, "b", 2, "c"])) or \
80-
idx2.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
80+
if idx1.equals(Index([0, "a", 1, "b", 2, "c"])) or idx2.equals(
81+
Index([0, "a", 1, "b", 2, "c"])
82+
):
8183
idx1 = idx1.astype(str)
8284
idx2 = idx2.astype(str)
8385

@@ -130,6 +132,7 @@ def test_union_different_types(index_flat, index_flat2, request):
130132
assert res1.dtype == common_dtype
131133
assert res2.dtype == common_dtype
132134

135+
133136
@pytest.mark.parametrize(
134137
"idx1,idx2",
135138
[
@@ -234,14 +237,13 @@ def test_intersection_base(self, index):
234237

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

241243
index = index.unique()
242244

243245
# Mixed int string
244-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
246+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
245247
index = index.astype(str)
246248

247249
first = index[3:]
@@ -296,7 +298,6 @@ def test_difference_base(self, sort, index):
296298

297299
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
298300
def test_symmetric_difference(self, index, using_infer_string, request):
299-
300301
if (
301302
using_infer_string
302303
and index.dtype == "object"
@@ -311,7 +312,7 @@ def test_symmetric_difference(self, index, using_infer_string, request):
311312
# index fixture has e.g. an index of bools that does not satisfy this,
312313
# another with [0, 0, 1, 1, 2, 2]
313314
pytest.skip("Index values no not satisfy test condition.")
314-
if index.equals(pd.Index([0, "a", 1, "b", 2, "c"])):
315+
if index.equals(Index([0, "a", 1, "b", 2, "c"])):
315316
index = index.astype(str)
316317
first = index[1:]
317318
second = index[:-1]
@@ -920,8 +921,9 @@ def test_symmetric_difference_mi(self, sort):
920921
index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)])
921922

922923
def has_mixed_types(level):
923-
return any(isinstance(x, str) for x in level) and \
924-
any(isinstance(x, int) for x in level)
924+
return any(isinstance(x, str) for x in level) and any(
925+
isinstance(x, int) for x in level
926+
)
925927

926928
for idx in [index1, index2]:
927929
for lvl in range(idx.nlevels):

pandas/tests/test_algos.py

Lines changed: 3 additions & 8 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)
@@ -94,11 +91,9 @@ def test_factorize(self, index_or_series_obj, sort):
9491
if expected_uniques.dtype == bool and obj.dtype == object:
9592
expected_uniques = expected_uniques.astype(object)
9693

97-
9894
if sort:
9995
expected_uniques = expected_uniques.sort_values()
10096

101-
10297
# construct an integer ndarray so that
10398
# `expected_uniques.take(expected_codes)` is equal to `obj`
10499
expected_uniques_list = list(expected_uniques)

0 commit comments

Comments
 (0)