Skip to content

Commit f1056be

Browse files
committed
STYLE: Extending codespell to pandas/tests
1 parent 602ab16 commit f1056be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+139
-140
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ repos:
1616
- id: codespell
1717
types_or: [python, rst, markdown]
1818
files: ^(pandas|doc)/
19-
exclude: ^pandas/tests/
2019
- repo: https://github.com/pre-commit/pre-commit-hooks
2120
rev: v3.4.0
2221
hooks:

pandas/tests/arithmetic/test_timedelta64.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ def test_td64arr_add_sub_int(self, box_with_array, one):
11581158
msg = "Addition/subtraction of integers"
11591159
assert_invalid_addsub_type(tdarr, one, msg)
11601160

1161-
# TOOD: get inplace ops into assert_invalid_addsub_type
1161+
# TODO: get inplace ops into assert_invalid_addsub_type
11621162
with pytest.raises(TypeError, match=msg):
11631163
tdarr += one
11641164
with pytest.raises(TypeError, match=msg):

pandas/tests/arrays/categorical/test_missing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def test_fillna_array(self):
107107
other = cat.fillna("C")
108108
result = cat.fillna(other)
109109
tm.assert_categorical_equal(result, other)
110-
assert isna(cat[-1]) # didnt modify original inplace
110+
assert isna(cat[-1]) # didn't modify original inplace
111111

112112
other = np.array(["A", "B", "C", "B", "A"])
113113
result = cat.fillna(other)
114114
expected = Categorical(["A", "B", "C", "B", "A"], dtype=cat.dtype)
115115
tm.assert_categorical_equal(result, expected)
116-
assert isna(cat[-1]) # didnt modify original inplace
116+
assert isna(cat[-1]) # didn't modify original inplace
117117

118118
@pytest.mark.parametrize(
119119
"values, expected",

pandas/tests/arrays/sparse/test_array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_constructor_na_dtype(self, dtype):
9595
SparseArray([0, 1, np.nan], dtype=dtype)
9696

9797
def test_constructor_warns_when_losing_timezone(self):
98-
# GH#32501 warn when losing timezone inforamtion
98+
# GH#32501 warn when losing timezone information
9999
dti = pd.date_range("2016-01-01", periods=3, tz="US/Pacific")
100100

101101
expected = SparseArray(np.asarray(dti, dtype="datetime64[ns]"))

pandas/tests/computation/test_eval.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1144,11 +1144,11 @@ def test_performance_warning_for_poor_alignment(self, engine, parser):
11441144
if not is_python_engine:
11451145
assert len(w) == 1
11461146
msg = str(w[0].message)
1147-
loged = np.log10(s.size - df.shape[1])
1147+
logged = np.log10(s.size - df.shape[1])
11481148
expected = (
11491149
f"Alignment difference on axis 1 is larger "
11501150
f"than an order of magnitude on term 'df', "
1151-
f"by more than {loged:.4g}; performance may suffer"
1151+
f"by more than {logged:.4g}; performance may suffer"
11521152
)
11531153
assert msg == expected
11541154

@@ -1404,25 +1404,25 @@ def test_multi_line_expression(self):
14041404

14051405
expected["c"] = expected["a"] + expected["b"]
14061406
expected["d"] = expected["c"] + expected["b"]
1407-
ans = df.eval(
1407+
answer = df.eval(
14081408
"""
14091409
c = a + b
14101410
d = c + b""",
14111411
inplace=True,
14121412
)
14131413
tm.assert_frame_equal(expected, df)
1414-
assert ans is None
1414+
assert answer is None
14151415

14161416
expected["a"] = expected["a"] - 1
14171417
expected["e"] = expected["a"] + 2
1418-
ans = df.eval(
1418+
answer = df.eval(
14191419
"""
14201420
a = a - 1
14211421
e = a + 2""",
14221422
inplace=True,
14231423
)
14241424
tm.assert_frame_equal(expected, df)
1425-
assert ans is None
1425+
assert answer is None
14261426

14271427
# multi-line not valid if not all assignments
14281428
msg = "Multi-line expressions are only valid if all expressions contain"
@@ -1467,15 +1467,15 @@ def test_multi_line_expression_local_variable(self):
14671467
local_var = 7
14681468
expected["c"] = expected["a"] * local_var
14691469
expected["d"] = expected["c"] + local_var
1470-
ans = df.eval(
1470+
answer = df.eval(
14711471
"""
14721472
c = a * @local_var
14731473
d = c + @local_var
14741474
""",
14751475
inplace=True,
14761476
)
14771477
tm.assert_frame_equal(expected, df)
1478-
assert ans is None
1478+
assert answer is None
14791479

14801480
def test_multi_line_expression_callable_local_variable(self):
14811481
# 26426
@@ -1487,15 +1487,15 @@ def local_func(a, b):
14871487
expected = df.copy()
14881488
expected["c"] = expected["a"] * local_func(1, 7)
14891489
expected["d"] = expected["c"] + local_func(1, 7)
1490-
ans = df.eval(
1490+
answer = df.eval(
14911491
"""
14921492
c = a * @local_func(1, 7)
14931493
d = c + @local_func(1, 7)
14941494
""",
14951495
inplace=True,
14961496
)
14971497
tm.assert_frame_equal(expected, df)
1498-
assert ans is None
1498+
assert answer is None
14991499

15001500
def test_multi_line_expression_callable_local_variable_with_kwargs(self):
15011501
# 26426
@@ -1507,15 +1507,15 @@ def local_func(a, b):
15071507
expected = df.copy()
15081508
expected["c"] = expected["a"] * local_func(b=7, a=1)
15091509
expected["d"] = expected["c"] + local_func(b=7, a=1)
1510-
ans = df.eval(
1510+
answer = df.eval(
15111511
"""
15121512
c = a * @local_func(b=7, a=1)
15131513
d = c + @local_func(b=7, a=1)
15141514
""",
15151515
inplace=True,
15161516
)
15171517
tm.assert_frame_equal(expected, df)
1518-
assert ans is None
1518+
assert answer is None
15191519

15201520
def test_assignment_in_query(self):
15211521
# GH 8664

pandas/tests/config/test_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def test_describe_option(self):
112112

113113
# if no doc is specified we get a default message
114114
# saying "description not available"
115-
assert "vailable" in self.cf.describe_option("f", _print_desc=False)
116-
assert "vailable" in self.cf.describe_option("g.h", _print_desc=False)
115+
assert "available" in self.cf.describe_option("f", _print_desc=False)
116+
assert "available" in self.cf.describe_option("g.h", _print_desc=False)
117117
assert "precated" in self.cf.describe_option("g.h", _print_desc=False)
118118
assert "k" in self.cf.describe_option("g.h", _print_desc=False)
119119

pandas/tests/dtypes/cast/test_promote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _assert_match(result_fill_value, expected_fill_value):
103103

104104
if hasattr(result_fill_value, "dtype"):
105105
# Compare types in a way that is robust to platform-specific
106-
# idiosyncracies where e.g. sometimes we get "ulonglong" as an alias
106+
# idiosyncrasies where e.g. sometimes we get "ulonglong" as an alias
107107
# for "uint64" or "intc" as an alias for "int32"
108108
assert result_fill_value.dtype.kind == expected_fill_value.dtype.kind
109109
assert result_fill_value.dtype.itemsize == expected_fill_value.dtype.itemsize

pandas/tests/dtypes/test_missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def test_array_equivalent_nested():
553553
)
554554
def test_na_value_for_dtype(dtype, na_value):
555555
result = na_value_for_dtype(dtype)
556-
# identify check doesnt work for datetime64/timedelta64("NaT") bc they
556+
# identify check doesn't work for datetime64/timedelta64("NaT") bc they
557557
# are not singletons
558558
assert result is na_value or (
559559
isna(result) and isna(na_value) and type(result) is type(na_value)

pandas/tests/extension/base/dim2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_reductions_2d_axis1(self, data, method, request):
238238
else:
239239
raise AssertionError("Both reductions should raise or neither")
240240

241-
# not necesarrily type/dtype-preserving, so weaker assertions
241+
# not necessarily type/dtype-preserving, so weaker assertions
242242
assert result.shape == (1,)
243243
expected_scalar = getattr(data, method)()
244244
if pd.isna(result[0]):

pandas/tests/extension/base/methods.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_argmin_argmax(self, data_for_sorting, data_missing_for_sorting, na_valu
9090
assert data_for_sorting.argmax() == 1
9191
assert data_for_sorting.argmin() == 2
9292

93-
# with repeated values -> first occurence
93+
# with repeated values -> first occurrence
9494
data = data_for_sorting.take([2, 0, 0, 1, 1, 2])
9595
assert data.argmax() == 3
9696
assert data.argmin() == 0
@@ -109,7 +109,7 @@ def test_argmin_argmax_empty_array(self, method, data):
109109

110110
@pytest.mark.parametrize("method", ["argmax", "argmin"])
111111
def test_argmin_argmax_all_na(self, method, data, na_value):
112-
# all missing with skipna=True is the same as emtpy
112+
# all missing with skipna=True is the same as empty
113113
err_msg = "attempt to get"
114114
data_na = type(data)._from_sequence([na_value, na_value], dtype=data.dtype)
115115
with pytest.raises(ValueError, match=err_msg):
@@ -530,7 +530,7 @@ def test_equals(self, data, na_value, as_series, box):
530530
# different length
531531
assert data[:2].equals(data[:3]) is False
532532

533-
# emtpy are equal
533+
# empty are equal
534534
assert data[:0].equals(data[:0]) is True
535535

536536
# other types

pandas/tests/extension/test_boolean.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def test_argmin_argmax(self, data_for_sorting, data_missing_for_sorting):
234234
assert data_for_sorting.argmax() == 0
235235
assert data_for_sorting.argmin() == 2
236236

237-
# with repeated values -> first occurence
237+
# with repeated values -> first occurrence
238238
data = data_for_sorting.take([2, 0, 0, 1, 1, 2])
239239
assert data.argmax() == 1
240240
assert data.argmin() == 0

pandas/tests/frame/indexing/test_indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ def test_setitem_corner(self, float_frame):
439439
dm["foo"] = "bar"
440440
assert dm["foo"].dtype == np.object_
441441

442-
dm["coercable"] = ["1", "2", "3"]
443-
assert dm["coercable"].dtype == np.object_
442+
dm["coercible"] = ["1", "2", "3"]
443+
assert dm["coercible"].dtype == np.object_
444444

445445
def test_setitem_corner2(self):
446446
data = {

pandas/tests/frame/indexing/test_setitem.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def test_setitem_intervals(self):
420420
assert isinstance(ser.cat.categories, IntervalIndex)
421421

422422
# B & D end up as Categoricals
423-
# the remainer are converted to in-line objects
423+
# the remainder are converted to in-line objects
424424
# containing an IntervalIndex.values
425425
df["B"] = ser
426426
df["C"] = np.array(ser)
@@ -433,13 +433,13 @@ def test_setitem_intervals(self):
433433
assert is_categorical_dtype(df["D"].dtype)
434434
assert is_interval_dtype(df["D"].cat.categories)
435435

436-
# Thes goes through the Series constructor and so get inferred back
436+
# These goes through the Series constructor and so get inferred back
437437
# to IntervalDtype
438438
assert is_interval_dtype(df["C"])
439439
assert is_interval_dtype(df["E"])
440440

441441
# But the Series constructor doesn't do inference on Series objects,
442-
# so setting df["F"] doesnt get cast back to IntervalDtype
442+
# so setting df["F"] doesn't get cast back to IntervalDtype
443443
assert is_object_dtype(df["F"])
444444

445445
# they compare equal as Index

pandas/tests/frame/methods/test_cov_corr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_corr_item_cache(self, using_array_manager):
207207

208208
_ = df.corr()
209209

210-
# Check that the corr didnt break link between ser and df
210+
# Check that the corr didn't break link between ser and df
211211
ser.values[0] = 99
212212
assert df.loc[0, "A"] == 99
213213
assert df["A"] is ser

pandas/tests/frame/methods/test_quantile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,11 @@ class TestQuantileExtensionDtype:
550550
pd.date_range("2016-01-01", periods=9, tz="US/Pacific"),
551551
pytest.param(
552552
pd.array(np.arange(9), dtype="Int64"),
553-
marks=pytest.mark.xfail(reason="doesnt implement from_factorized"),
553+
marks=pytest.mark.xfail(reason="doesn't implement from_factorized"),
554554
),
555555
pytest.param(
556556
pd.array(np.arange(9), dtype="Float64"),
557-
marks=pytest.mark.xfail(reason="doesnt implement from_factorized"),
557+
marks=pytest.mark.xfail(reason="doesn't implement from_factorized"),
558558
),
559559
],
560560
ids=lambda x: str(x.dtype),

pandas/tests/frame/methods/test_replace.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,8 @@ def test_categorical_replace_with_dict(self, replace_dict, final_data):
14391439

14401440
a = pd.Categorical(final_data[:, 0], categories=[3, 2])
14411441

1442-
excat = [3, 2] if replace_dict["b"] == 1 else [1, 3]
1443-
b = pd.Categorical(final_data[:, 1], categories=excat)
1442+
ex_cat = [3, 2] if replace_dict["b"] == 1 else [1, 3]
1443+
b = pd.Categorical(final_data[:, 1], categories=ex_cat)
14441444

14451445
expected = DataFrame({"a": a, "b": b})
14461446
result = df.replace(replace_dict, 3)

pandas/tests/frame/methods/test_reset_index.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def test_reset_index(self, float_frame):
137137

138138
# preserve column names
139139
float_frame.columns.name = "columns"
140-
resetted = float_frame.reset_index()
141-
assert resetted.columns.name == "columns"
140+
reset = float_frame.reset_index()
141+
assert reset.columns.name == "columns"
142142

143143
# only remove certain columns
144144
df = float_frame.reset_index().set_index(["index", "A", "B"])
@@ -159,10 +159,10 @@ def test_reset_index(self, float_frame):
159159

160160
# test resetting in place
161161
df = float_frame.copy()
162-
resetted = float_frame.reset_index()
162+
reset = float_frame.reset_index()
163163
return_value = df.reset_index(inplace=True)
164164
assert return_value is None
165-
tm.assert_frame_equal(df, resetted, check_names=False)
165+
tm.assert_frame_equal(df, reset, check_names=False)
166166

167167
df = float_frame.reset_index().set_index(["index", "A", "B"])
168168
rs = df.reset_index("A", drop=True)
@@ -224,11 +224,11 @@ def test_reset_index_right_dtype(self):
224224
)
225225
df = DataFrame(s1)
226226

227-
resetted = s1.reset_index()
228-
assert resetted["time"].dtype == np.float64
227+
reset = s1.reset_index()
228+
assert reset["time"].dtype == np.float64
229229

230-
resetted = df.reset_index()
231-
assert resetted["time"].dtype == np.float64
230+
reset = df.reset_index()
231+
assert reset["time"].dtype == np.float64
232232

233233
def test_reset_index_multiindex_col(self):
234234
vals = np.random.randn(3, 3).astype(object)

pandas/tests/frame/methods/test_to_dict_of_blocks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_to_dict_of_blocks_item_cache():
5353

5454
df._to_dict_of_blocks()
5555

56-
# Check that the to_dict_of_blocks didnt break link between ser and df
56+
# Check that the to_dict_of_blocks didn't break link between ser and df
5757
ser.values[0] = "foo"
5858
assert df.loc[0, "b"] == "foo"
5959

pandas/tests/frame/methods/test_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_frame_values_with_tz(self):
9191
)
9292
tm.assert_numpy_array_equal(result, expected)
9393

94-
# two columns, homogenous
94+
# two columns, homogeneous
9595

9696
df["B"] = df["A"]
9797
result = df.values

pandas/tests/frame/test_block_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def test_update_inplace_sets_valid_block_values():
388388
# inplace update of a single column
389389
df["a"].fillna(1, inplace=True)
390390

391-
# check we havent put a Series into any block.values
391+
# check we haven't put a Series into any block.values
392392
assert isinstance(df._mgr.blocks[0].values, Categorical)
393393

394394
# smoketest for OP bug from GH#35731

pandas/tests/frame/test_constructors.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ def test_constructor_unequal_length_nested_list_column(self):
11951195

11961196
def test_constructor_sequence_like(self):
11971197
# GH 3783
1198-
# collections.Squence like
1198+
# collections.Sequence like
11991199

12001200
class DummyContainer(abc.Sequence):
12011201
def __init__(self, lst):
@@ -1426,9 +1426,9 @@ def test_constructor_list_of_dataclasses(self):
14261426

14271427
Point = make_dataclass("Point", [("x", int), ("y", int)])
14281428

1429-
datas = [Point(0, 3), Point(1, 3)]
1429+
data = [Point(0, 3), Point(1, 3)]
14301430
expected = DataFrame({"x": [0, 1], "y": [3, 3]})
1431-
result = DataFrame(datas)
1431+
result = DataFrame(data)
14321432
tm.assert_frame_equal(result, expected)
14331433

14341434
def test_constructor_list_of_dataclasses_with_varying_types(self):
@@ -1439,12 +1439,12 @@ def test_constructor_list_of_dataclasses_with_varying_types(self):
14391439
Point = make_dataclass("Point", [("x", int), ("y", int)])
14401440
HLine = make_dataclass("HLine", [("x0", int), ("x1", int), ("y", int)])
14411441

1442-
datas = [Point(0, 3), HLine(1, 3, 3)]
1442+
data = [Point(0, 3), HLine(1, 3, 3)]
14431443

14441444
expected = DataFrame(
14451445
{"x": [0, np.nan], "y": [3, 3], "x0": [np.nan, 1], "x1": [np.nan, 3]}
14461446
)
1447-
result = DataFrame(datas)
1447+
result = DataFrame(data)
14481448
tm.assert_frame_equal(result, expected)
14491449

14501450
def test_constructor_list_of_dataclasses_error_thrown(self):
@@ -1912,7 +1912,7 @@ def test_constructor_for_list_with_dtypes(self):
19121912
expected = Series([np.dtype("int64")] * 5)
19131913
tm.assert_series_equal(result, expected)
19141914

1915-
# overflow issue? (we always expecte int64 upcasting here)
1915+
# overflow issue? (we always expected int64 upcasting here)
19161916
df = DataFrame({"a": [2 ** 31, 2 ** 31 + 1]})
19171917
assert df.dtypes.iloc[0] == np.dtype("int64")
19181918

0 commit comments

Comments
 (0)