Skip to content

Commit 082d437

Browse files
authored
STYLE: Extending codespell to pandas/tests/ part3 38802 (#40372)
* STYLE: Extending codespell to pandas/tests part 3 * DOC: small change in test_internals.py * TST: small changes in test_to_xml.py
1 parent bf31347 commit 082d437

24 files changed

+49
-50
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/indexing/multiindex/test_loc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def test_loc_multiindex_incomplete(self):
264264
tm.assert_series_equal(result, expected)
265265

266266
# GH 7400
267-
# multiindexer gettitem with list of indexers skips wrong element
267+
# multiindexer getitem with list of indexers skips wrong element
268268
s = Series(
269269
np.arange(15, dtype="int64"),
270270
MultiIndex.from_product([range(5), ["a", "b", "c"]]),
@@ -385,7 +385,7 @@ def test_multiindex_setitem_columns_enlarging(self, indexer, exp_value):
385385
[
386386
([], []), # empty ok
387387
(["A"], slice(3)),
388-
(["A", "D"], []), # "D" isnt present -> raise
388+
(["A", "D"], []), # "D" isn't present -> raise
389389
(["D", "E"], []), # no values found -> raise
390390
(["D"], []), # same, with single item list: GH 27148
391391
(pd.IndexSlice[:, ["foo"]], slice(2, None, 3)),
@@ -531,7 +531,7 @@ def test_loc_period_string_indexing():
531531
# GH 9892
532532
a = pd.period_range("2013Q1", "2013Q4", freq="Q")
533533
i = (1111, 2222, 3333)
534-
idx = MultiIndex.from_product((a, i), names=("Periode", "CVR"))
534+
idx = MultiIndex.from_product((a, i), names=("Period", "CVR"))
535535
df = DataFrame(
536536
index=idx,
537537
columns=(
@@ -552,7 +552,7 @@ def test_loc_period_string_indexing():
552552
dtype=object,
553553
name="OMS",
554554
index=MultiIndex.from_tuples(
555-
[(pd.Period("2013Q1"), 1111)], names=["Periode", "CVR"]
555+
[(pd.Period("2013Q1"), 1111)], names=["Period", "CVR"]
556556
),
557557
)
558558
tm.assert_series_equal(result, expected)

pandas/tests/indexing/test_loc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ def test_loc_setitem_str_to_small_float_conversion_type(self):
10721072
tm.assert_frame_equal(result, expected)
10731073

10741074
# assigning with loc/iloc attempts to set the values inplace, which
1075-
# in this case is succesful
1075+
# in this case is successful
10761076
result.loc[result.index, "A"] = [float(x) for x in col_data]
10771077
expected = DataFrame(col_data, columns=["A"], dtype=float).astype(object)
10781078
tm.assert_frame_equal(result, expected)

pandas/tests/internals/test_internals.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ def assert_slice_ok(mgr, axis, slobj):
829829
elif mgr.ndim == 1 and axis == 0:
830830
sliced = mgr.getitem_mgr(slobj)
831831
else:
832-
# BlockManager doesnt support non-slice, SingleBlockManager
833-
# doesnt support axis > 0
832+
# BlockManager doesn't support non-slice, SingleBlockManager
833+
# doesn't support axis > 0
834834
return
835835

836836
mat_slobj = (slice(None),) * axis + (slobj,)

pandas/tests/io/pytables/test_append.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def test_append_frame_column_oriented(setup_path):
281281

282282
# column oriented
283283
df = tm.makeTimeDataFrame()
284-
df.index = df.index._with_freq(None) # freq doesnt round-trip
284+
df.index = df.index._with_freq(None) # freq doesn't round-trip
285285

286286
_maybe_remove(store, "df1")
287287
store.append("df1", df.iloc[:, :2], axes=["columns"])
@@ -331,7 +331,7 @@ def test_append_with_different_block_ordering(setup_path):
331331
store.append("df", df)
332332

333333
# test a different ordering but with more fields (like invalid
334-
# combinate)
334+
# combinations)
335335
with ensure_clean_store(setup_path) as store:
336336

337337
df = DataFrame(np.random.randn(10, 2), columns=list("AB"), dtype="float64")

pandas/tests/io/pytables/test_round_trip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def test_timeseries_preepoch(setup_path):
350350
try:
351351
_check_roundtrip(ts, tm.assert_series_equal, path=setup_path)
352352
except OverflowError:
353-
pytest.skip("known failer on some windows platforms")
353+
pytest.skip("known failure on some windows platforms")
354354

355355

356356
@pytest.mark.parametrize(

pandas/tests/io/pytables/test_select.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,13 @@ def test_frame_select_complex(setup_path):
663663

664664
def test_frame_select_complex2(setup_path):
665665

666-
with ensure_clean_path(["parms.hdf", "hist.hdf"]) as paths:
666+
with ensure_clean_path(["params.hdf", "hist.hdf"]) as paths:
667667

668668
pp, hh = paths
669669

670670
# use non-trivial selection criteria
671-
parms = DataFrame({"A": [1, 1, 2, 2, 3]})
672-
parms.to_hdf(pp, "df", mode="w", format="table", data_columns=["A"])
671+
params = DataFrame({"A": [1, 1, 2, 2, 3]})
672+
params.to_hdf(pp, "df", mode="w", format="table", data_columns=["A"])
673673

674674
selection = read_hdf(pp, "df", where="A=[2,3]")
675675
hist = DataFrame(

pandas/tests/io/pytables/test_timezones.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_append_with_timezones_as_index(setup_path, gettz):
137137
# GH#4098 example
138138

139139
dti = date_range("2000-1-1", periods=3, freq="H", tz=gettz("US/Eastern"))
140-
dti = dti._with_freq(None) # freq doesnt round-trip
140+
dti = dti._with_freq(None) # freq doesn't round-trip
141141

142142
df = DataFrame({"A": Series(range(3), index=dti)})
143143

@@ -217,7 +217,7 @@ def test_timezones_fixed_format_frame_non_empty(setup_path):
217217

218218
# index
219219
rng = date_range("1/1/2000", "1/30/2000", tz="US/Eastern")
220-
rng = rng._with_freq(None) # freq doesnt round-trip
220+
rng = rng._with_freq(None) # freq doesn't round-trip
221221
df = DataFrame(np.random.randn(len(rng), 4), index=rng)
222222
store["df"] = df
223223
result = store["df"]
@@ -334,7 +334,7 @@ def test_dst_transitions(setup_path):
334334
freq="H",
335335
ambiguous="infer",
336336
)
337-
times = times._with_freq(None) # freq doesnt round-trip
337+
times = times._with_freq(None) # freq doesn't round-trip
338338

339339
for i in [times, times + pd.Timedelta("10min")]:
340340
_maybe_remove(store, "df")

pandas/tests/io/xml/test_to_xml.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,12 @@ def test_attrs_cols_prefix(datapath, parser):
411411

412412
def test_attrs_unknown_column(parser):
413413
with pytest.raises(KeyError, match=("no valid column")):
414-
geom_df.to_xml(attr_cols=["shape", "degreees", "sides"], parser=parser)
414+
geom_df.to_xml(attr_cols=["shape", "degree", "sides"], parser=parser)
415415

416416

417417
def test_attrs_wrong_type(parser):
418418
with pytest.raises(TypeError, match=("is not a valid type for attr_cols")):
419-
geom_df.to_xml(attr_cols='"shape", "degreees", "sides"', parser=parser)
419+
geom_df.to_xml(attr_cols='"shape", "degree", "sides"', parser=parser)
420420

421421

422422
# ELEM_COLS
@@ -453,12 +453,12 @@ def test_elems_cols_nan_output(datapath, parser):
453453

454454
def test_elems_unknown_column(parser):
455455
with pytest.raises(KeyError, match=("no valid column")):
456-
geom_df.to_xml(elem_cols=["shape", "degreees", "sides"], parser=parser)
456+
geom_df.to_xml(elem_cols=["shape", "degree", "sides"], parser=parser)
457457

458458

459459
def test_elems_wrong_type(parser):
460460
with pytest.raises(TypeError, match=("is not a valid type for elem_cols")):
461-
geom_df.to_xml(elem_cols='"shape", "degreees", "sides"', parser=parser)
461+
geom_df.to_xml(elem_cols='"shape", "degree", "sides"', parser=parser)
462462

463463

464464
def test_elems_and_attrs_cols(datapath, parser):

pandas/tests/libs/test_hashtable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_no_reallocation(self, table_type, dtype):
170170
n_buckets_start = preallocated_table.get_state()["n_buckets"]
171171
preallocated_table.map_locations(keys)
172172
n_buckets_end = preallocated_table.get_state()["n_buckets"]
173-
# orgininal number of buckets was enough:
173+
# original number of buckets was enough:
174174
assert n_buckets_start == n_buckets_end
175175
# check with clean table (not too much preallocated)
176176
clean_table = table_type()
@@ -219,7 +219,7 @@ def test_no_reallocation_StringHashTable():
219219
n_buckets_start = preallocated_table.get_state()["n_buckets"]
220220
preallocated_table.map_locations(keys)
221221
n_buckets_end = preallocated_table.get_state()["n_buckets"]
222-
# orgininal number of buckets was enough:
222+
# original number of buckets was enough:
223223
assert n_buckets_start == n_buckets_end
224224
# check with clean table (not too much preallocated)
225225
clean_table = ht.StringHashTable()

pandas/tests/plotting/frame/test_frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ def test_xlabel_ylabel_dataframe_single_plot(
22082208
assert ax.get_xlabel() == old_label
22092209
assert ax.get_ylabel() == ""
22102210

2211-
# old xlabel will be overriden and assigned ylabel will be used as ylabel
2211+
# old xlabel will be overridden and assigned ylabel will be used as ylabel
22122212
ax = df.plot(kind=kind, ylabel=new_label, xlabel=new_label)
22132213
assert ax.get_ylabel() == str(new_label)
22142214
assert ax.get_xlabel() == str(new_label)

pandas/tests/plotting/frame/test_frame_subplots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def test_xlabel_ylabel_dataframe_subplots(
522522
assert all(ax.get_ylabel() == "" for ax in axes)
523523
assert all(ax.get_xlabel() == old_label for ax in axes)
524524

525-
# old xlabel will be overriden and assigned ylabel will be used as ylabel
525+
# old xlabel will be overridden and assigned ylabel will be used as ylabel
526526
axes = df.plot(kind=kind, ylabel=new_label, xlabel=new_label, subplots=True)
527527
assert all(ax.get_ylabel() == str(new_label) for ax in axes)
528528
assert all(ax.get_xlabel() == str(new_label) for ax in axes)

pandas/tests/plotting/test_hist_method.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def test_hist_secondary_legend(self):
533533
_, ax = self.plt.subplots()
534534
ax = df["a"].plot.hist(legend=True, ax=ax)
535535
df["b"].plot.hist(ax=ax, legend=True, secondary_y=True)
536-
# both legends are dran on left ax
536+
# both legends are drawn on left ax
537537
# left and right axis must be visible
538538
self._check_legend_labels(ax, labels=["a", "b (right)"])
539539
assert ax.get_yaxis().get_visible()

pandas/tests/plotting/test_series.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def test_df_series_secondary_legend(self):
381381
_, ax = self.plt.subplots()
382382
ax = df.plot(ax=ax)
383383
s.plot(legend=True, secondary_y=True, ax=ax)
384-
# both legends are dran on left ax
384+
# both legends are drawn on left ax
385385
# left and right axis must be visible
386386
self._check_legend_labels(ax, labels=["a", "b", "c", "x (right)"])
387387
assert ax.get_yaxis().get_visible()
@@ -392,7 +392,7 @@ def test_df_series_secondary_legend(self):
392392
_, ax = self.plt.subplots()
393393
ax = df.plot(ax=ax)
394394
s.plot(ax=ax, legend=True, secondary_y=True)
395-
# both legends are dran on left ax
395+
# both legends are drawn on left ax
396396
# left and right axis must be visible
397397
self._check_legend_labels(ax, labels=["a", "b", "c", "x (right)"])
398398
assert ax.get_yaxis().get_visible()
@@ -403,7 +403,7 @@ def test_df_series_secondary_legend(self):
403403
_, ax = self.plt.subplots()
404404
ax = df.plot(secondary_y=True, ax=ax)
405405
s.plot(legend=True, secondary_y=True, ax=ax)
406-
# both legends are dran on left ax
406+
# both legends are drawn on left ax
407407
# left axis must be invisible and right axis must be visible
408408
expected = ["a (right)", "b (right)", "c (right)", "x (right)"]
409409
self._check_legend_labels(ax.left_ax, labels=expected)
@@ -415,7 +415,7 @@ def test_df_series_secondary_legend(self):
415415
_, ax = self.plt.subplots()
416416
ax = df.plot(secondary_y=True, ax=ax)
417417
s.plot(ax=ax, legend=True, secondary_y=True)
418-
# both legends are dran on left ax
418+
# both legends are drawn on left ax
419419
# left axis must be invisible and right axis must be visible
420420
expected = ["a (right)", "b (right)", "c (right)", "x (right)"]
421421
self._check_legend_labels(ax.left_ax, expected)
@@ -427,7 +427,7 @@ def test_df_series_secondary_legend(self):
427427
_, ax = self.plt.subplots()
428428
ax = df.plot(secondary_y=True, mark_right=False, ax=ax)
429429
s.plot(ax=ax, legend=True, secondary_y=True)
430-
# both legends are dran on left ax
430+
# both legends are drawn on left ax
431431
# left axis must be invisible and right axis must be visible
432432
expected = ["a", "b", "c", "x (right)"]
433433
self._check_legend_labels(ax.left_ax, expected)
@@ -798,7 +798,7 @@ def test_xlabel_ylabel_series(self, kind, index_name, old_label, new_label):
798798
assert ax.get_ylabel() == ""
799799
assert ax.get_xlabel() == old_label
800800

801-
# old xlabel will be overriden and assigned ylabel will be used as ylabel
801+
# old xlabel will be overridden and assigned ylabel will be used as ylabel
802802
ax = ser.plot(kind=kind, ylabel=new_label, xlabel=new_label)
803803
assert ax.get_ylabel() == new_label
804804
assert ax.get_xlabel() == new_label

pandas/tests/reshape/concat/test_datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def test_concat_tz_not_aligned(self):
457457
)
458458
def test_concat_tz_NaT(self, t1):
459459
# GH#22796
460-
# Concating tz-aware multicolumn DataFrames
460+
# Concatenating tz-aware multicolumn DataFrames
461461
ts1 = Timestamp(t1, tz="UTC")
462462
ts2 = Timestamp("2015-01-01", tz="UTC")
463463
ts3 = Timestamp("2015-01-01", tz="UTC")

pandas/tests/reshape/merge/test_merge_ordered.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,19 @@ def test_list_type_by(self, left, right, on, left_by, right_by, expected):
183183

184184
def test_left_by_length_equals_to_right_shape0(self):
185185
# GH 38166
186-
left = DataFrame([["g", "h", 1], ["g", "h", 3]], columns=list("GHT"))
187-
right = DataFrame([[2, 1]], columns=list("TE"))
188-
result = merge_ordered(left, right, on="T", left_by=["G", "H"])
186+
left = DataFrame([["g", "h", 1], ["g", "h", 3]], columns=list("GHE"))
187+
right = DataFrame([[2, 1]], columns=list("ET"))
188+
result = merge_ordered(left, right, on="E", left_by=["G", "H"])
189189
expected = DataFrame(
190-
{"G": ["g"] * 3, "H": ["h"] * 3, "T": [1, 2, 3], "E": [np.nan, 1.0, np.nan]}
190+
{"G": ["g"] * 3, "H": ["h"] * 3, "E": [1, 2, 3], "T": [np.nan, 1.0, np.nan]}
191191
)
192192

193193
tm.assert_frame_equal(result, expected)
194194

195195
def test_elements_not_in_by_but_in_df(self):
196196
# GH 38167
197-
left = DataFrame([["g", "h", 1], ["g", "h", 3]], columns=list("GHT"))
198-
right = DataFrame([[2, 1]], columns=list("TE"))
197+
left = DataFrame([["g", "h", 1], ["g", "h", 3]], columns=list("GHE"))
198+
right = DataFrame([[2, 1]], columns=list("ET"))
199199
msg = r"\{'h'\} not found in left columns"
200200
with pytest.raises(KeyError, match=msg):
201-
merge_ordered(left, right, on="T", left_by=["G", "h"])
201+
merge_ordered(left, right, on="E", left_by=["G", "h"])

pandas/tests/scalar/test_nat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,15 @@ def test_to_numpy_alias():
527527
pytest.param(
528528
Timedelta(0).to_timedelta64(),
529529
marks=pytest.mark.xfail(
530-
reason="td64 doesnt return NotImplemented, see numpy#17017"
530+
reason="td64 doesn't return NotImplemented, see numpy#17017"
531531
),
532532
),
533533
Timestamp(0),
534534
Timestamp(0).to_pydatetime(),
535535
pytest.param(
536536
Timestamp(0).to_datetime64(),
537537
marks=pytest.mark.xfail(
538-
reason="dt64 doesnt return NotImplemented, see numpy#17017"
538+
reason="dt64 doesn't return NotImplemented, see numpy#17017"
539539
),
540540
),
541541
Timestamp(0).tz_localize("UTC"),

pandas/tests/series/methods/test_convert_dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# test Series, the default dtype for the expected result (which is valid
1313
# for most cases), and the specific cases where the result deviates from
1414
# this default. Those overrides are defined as a dict with (keyword, val) as
15-
# dictionary key. In case of multiple items, the last override takes precendence.
15+
# dictionary key. In case of multiple items, the last override takes precedence.
1616
test_cases = [
1717
(
1818
# data

pandas/tests/series/methods/test_nlargest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class TestSeriesNLargestNSmallest:
9898
)
9999
def test_nlargest_error(self, r):
100100
dt = r.dtype
101-
msg = f"Cannot use method 'n(larg|small)est' with dtype {dt}"
101+
msg = f"Cannot use method 'n(largest|smallest)' with dtype {dt}"
102102
args = 2, len(r), 0, -1
103103
methods = r.nlargest, r.nsmallest
104104
for method, arg in product(methods, args):

pandas/tests/series/methods/test_to_csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def read_csv(self, path, **kwargs):
2525
return out
2626

2727
def test_from_csv(self, datetime_series, string_series):
28-
# freq doesnt round-trip
28+
# freq doesn't round-trip
2929
datetime_series.index = datetime_series.index._with_freq(None)
3030

3131
with tm.ensure_clean() as path:

pandas/tests/strings/test_cat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_str_cat_name(index_or_series, other):
2828
def test_str_cat(index_or_series):
2929
box = index_or_series
3030
# test_cat above tests "str_cat" from ndarray;
31-
# here testing "str.cat" from Series/Indext to ndarray/list
31+
# here testing "str.cat" from Series/Index to ndarray/list
3232
s = box(["a", "a", "b", "b", "c", np.nan])
3333

3434
# single array

pandas/tests/tools/test_to_datetime.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def test_to_datetime_YYYYMMDD(self):
515515
assert actual == datetime(2008, 1, 15)
516516

517517
def test_to_datetime_unparseable_ignore(self):
518-
# unparseable
518+
# unparsable
519519
s = "Month 1, 1999"
520520
assert to_datetime(s, errors="ignore") == s
521521

@@ -2469,7 +2469,7 @@ def test_empty_string_datetime_coerce__format():
24692469
with pytest.raises(ValueError, match="does not match format"):
24702470
result = to_datetime(td, format=format, errors="raise")
24712471

2472-
# don't raise an expection in case no format is given
2472+
# don't raise an exception in case no format is given
24732473
result = to_datetime(td, errors="raise")
24742474
tm.assert_series_equal(result, expected)
24752475

pandas/tests/tseries/offsets/test_offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565

6666
class TestCommon(Base):
67-
# exected value created by Base._get_offset
67+
# executed value created by Base._get_offset
6868
# are applied to 2011/01/01 09:00 (Saturday)
6969
# used for .apply and .rollforward
7070
expecteds = {

pandas/tests/tslibs/test_fields.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def test_fields_readonly():
99
# https://github.com/vaexio/vaex/issues/357
10-
# fields functions should't raise when we pass read-only data
10+
# fields functions shouldn't raise when we pass read-only data
1111
dtindex = np.arange(5, dtype=np.int64) * 10 ** 9 * 3600 * 24 * 32
1212
dtindex.flags.writeable = False
1313

0 commit comments

Comments
 (0)