Skip to content

Commit 3cf05ed

Browse files
authored
STYLE: Extending codespell to pandas/tests (#40320)
* STYLE: Extending codespell to pandas/tests part 1 * FIX: Variable name made consistent.
1 parent c10dd1a commit 3cf05ed

22 files changed

+55
-53
lines changed

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/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

pandas/tests/frame/test_stack_unstack.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1462,9 +1462,9 @@ def test_unstack_odd_failure(self):
14621462
Sat,Dinner,Yes,120.77,42
14631463
Sun,Dinner,No,180.57,57
14641464
Sun,Dinner,Yes,66.82,19
1465-
Thur,Dinner,No,3.0,1
1466-
Thur,Lunch,No,117.32,44
1467-
Thur,Lunch,Yes,51.51,17"""
1465+
Thu,Dinner,No,3.0,1
1466+
Thu,Lunch,No,117.32,44
1467+
Thu,Lunch,Yes,51.51,17"""
14681468

14691469
df = pd.read_csv(StringIO(data)).set_index(["day", "time", "smoker"])
14701470

@@ -1490,7 +1490,7 @@ def test_stack_mixed_dtype(self, multiindex_dataframe_random_data):
14901490
def test_unstack_bug(self):
14911491
df = DataFrame(
14921492
{
1493-
"state": ["naive", "naive", "naive", "activ", "activ", "activ"],
1493+
"state": ["naive", "naive", "naive", "active", "active", "active"],
14941494
"exp": ["a", "b", "b", "b", "a", "a"],
14951495
"barcode": [1, 2, 3, 4, 1, 3],
14961496
"v": ["hi", "hi", "bye", "bye", "bye", "peace"],

pandas/tests/io/excel/test_readers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _is_valid_engine_ext_pair(engine, read_ext: str) -> bool:
7979

8080
def _transfer_marks(engine, read_ext):
8181
"""
82-
engine gives us a pytest.param objec with some marks, read_ext is just
82+
engine gives us a pytest.param object with some marks, read_ext is just
8383
a string. We need to generate a new pytest.param inheriting the marks.
8484
"""
8585
values = engine.values + (read_ext,)

pandas/tests/io/excel/test_writers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def test_mixed(self, frame, path):
436436
def test_ts_frame(self, tsframe, path):
437437
df = tsframe
438438

439-
# freq doesnt round-trip
439+
# freq doesn't round-trip
440440
index = pd.DatetimeIndex(np.asarray(df.index), freq=None)
441441
df.index = index
442442

@@ -515,7 +515,7 @@ def test_inf_roundtrip(self, path):
515515

516516
def test_sheets(self, frame, tsframe, path):
517517

518-
# freq doesnt round-trip
518+
# freq doesn't round-trip
519519
index = pd.DatetimeIndex(np.asarray(tsframe.index), freq=None)
520520
tsframe.index = index
521521

pandas/tests/io/formats/test_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ def test_east_asian_unicode_series(self):
22772277
)
22782278
assert repr(s) == expected
22792279

2280-
# Emable Unicode option -----------------------------------------
2280+
# Enable Unicode option -----------------------------------------
22812281
with option_context("display.unicode.east_asian_width", True):
22822282

22832283
# unicode index

pandas/tests/io/json/test_pandas.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def setup(self):
6363
@pytest.fixture
6464
def datetime_series(self):
6565
# Same as usual datetime_series, but with index freq set to None,
66-
# since that doesnt round-trip, see GH#33711
66+
# since that doesn't round-trip, see GH#33711
6767
ser = tm.makeTimeSeries()
6868
ser.name = "ts"
6969
ser.index = ser.index._with_freq(None)
@@ -72,7 +72,7 @@ def datetime_series(self):
7272
@pytest.fixture
7373
def datetime_frame(self):
7474
# Same as usual datetime_frame, but with index freq set to None,
75-
# since that doesnt round-trip, see GH#33711
75+
# since that doesn't round-trip, see GH#33711
7676
df = DataFrame(tm.getTimeSeriesData())
7777
df.index = df.index._with_freq(None)
7878
return df
@@ -459,7 +459,7 @@ def test_frame_mixedtype_orient(self): # GH10289
459459

460460
def test_v12_compat(self, datapath):
461461
dti = pd.date_range("2000-01-03", "2000-01-07")
462-
# freq doesnt roundtrip
462+
# freq doesn't roundtrip
463463
dti = DatetimeIndex(np.asarray(dti), freq=None)
464464
df = DataFrame(
465465
[
@@ -489,7 +489,7 @@ def test_v12_compat(self, datapath):
489489

490490
def test_blocks_compat_GH9037(self):
491491
index = pd.date_range("20000101", periods=10, freq="H")
492-
# freq doesnt round-trip
492+
# freq doesn't round-trip
493493
index = DatetimeIndex(list(index), freq=None)
494494

495495
df_mixed = DataFrame(
@@ -637,8 +637,10 @@ def test_series_non_unique_index(self):
637637
tm.assert_series_equal(
638638
s, read_json(s.to_json(orient="split"), orient="split", typ="series")
639639
)
640-
unser = read_json(s.to_json(orient="records"), orient="records", typ="series")
641-
tm.assert_numpy_array_equal(s.values, unser.values)
640+
unserialized = read_json(
641+
s.to_json(orient="records"), orient="records", typ="series"
642+
)
643+
tm.assert_numpy_array_equal(s.values, unserialized.values)
642644

643645
def test_series_default_orient(self, string_series):
644646
assert string_series.to_json() == string_series.to_json(orient="index")

pandas/tests/io/json/test_ujson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ def test_index(self):
10961096
def test_datetime_index(self):
10971097
date_unit = "ns"
10981098

1099-
# freq doesnt round-trip
1099+
# freq doesn't round-trip
11001100
rng = DatetimeIndex(list(date_range("1/1/2000", periods=20)), freq=None)
11011101
encoded = ujson.encode(rng, date_unit=date_unit)
11021102

pandas/tests/io/parser/common/test_common_basic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def test_escapechar(all_parsers):
356356
# https://stackoverflow.com/questions/13824840/feature-request-for-
357357
# pandas-read-csv
358358
data = '''SEARCH_TERM,ACTUAL_URL
359-
"bra tv bord","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
359+
"bra tv board","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
360360
"tv p\xc3\xa5 hjul","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
361361
"SLAGBORD, \\"Bergslagen\\", IKEA:s 1700-tals series","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"''' # noqa
362362

pandas/tests/io/parser/test_network.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def test_read_csv_handles_boto_s3_object(self, s3_resource, tips_file):
262262
tm.assert_frame_equal(result, expected)
263263

264264
def test_read_csv_chunked_download(self, s3_resource, caplog, s3so):
265-
# 8 MB, S3FS usees 5MB chunks
265+
# 8 MB, S3FS uses 5MB chunks
266266
import s3fs
267267

268268
df = DataFrame(np.random.randn(100000, 4), columns=list("abcd"))

0 commit comments

Comments
 (0)