Skip to content

Commit 9903a54

Browse files
authored
STYLE: Extending codespell to pandas/tests Part 2 (#40332)
* STYLE: Extending codespell to pandas/tests part 2 * DOC: small change in test_setitem.py
1 parent bfefa19 commit 9903a54

23 files changed

+44
-44
lines changed

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 go 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_subclass.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def test_subclassed_apply(self):
519519
def check_row_subclass(row):
520520
assert isinstance(row, tm.SubclassedSeries)
521521

522-
def strech(row):
522+
def stretch(row):
523523
if row["variable"] == "height":
524524
row["value"] += 0.5
525525
return row
@@ -547,7 +547,7 @@ def strech(row):
547547
columns=["first", "last", "variable", "value"],
548548
)
549549

550-
result = df.apply(lambda x: strech(x), axis=1)
550+
result = df.apply(lambda x: stretch(x), axis=1)
551551
assert isinstance(result, tm.SubclassedDataFrame)
552552
tm.assert_frame_equal(result, expected)
553553

pandas/tests/groupby/aggregate/test_aggregate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def test_agg_relabel_multiindex_column(
758758

759759

760760
def test_agg_relabel_multiindex_raises_not_exist():
761-
# GH 29422, add test for raises senario when aggregate column does not exist
761+
# GH 29422, add test for raises scenario when aggregate column does not exist
762762
df = DataFrame(
763763
{"group": ["a", "a", "b", "b"], "A": [0, 1, 2, 3], "B": [5, 6, 7, 8]}
764764
)
@@ -769,7 +769,7 @@ def test_agg_relabel_multiindex_raises_not_exist():
769769

770770

771771
def test_agg_relabel_multiindex_duplicates():
772-
# GH29422, add test for raises senario when getting duplicates
772+
# GH29422, add test for raises scenario when getting duplicates
773773
# GH28426, after this change, duplicates should also work if the relabelling is
774774
# different
775775
df = DataFrame(

pandas/tests/groupby/test_libgroupby.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ def _check_cython_group_transform_cumulative(pd_op, np_op, dtype):
176176
is_datetimelike = False
177177

178178
data = np.array([[1], [2], [3], [4]], dtype=dtype)
179-
ans = np.zeros_like(data)
179+
answer = np.zeros_like(data)
180180

181181
labels = np.array([0, 0, 0, 0], dtype=np.int64)
182182
ngroups = 1
183-
pd_op(ans, data, labels, ngroups, is_datetimelike)
183+
pd_op(answer, data, labels, ngroups, is_datetimelike)
184184

185-
tm.assert_numpy_array_equal(np_op(data), ans[:, 0], check_dtype=False)
185+
tm.assert_numpy_array_equal(np_op(data), answer[:, 0], check_dtype=False)
186186

187187

188188
def test_cython_group_transform_cumsum(any_real_dtype):

pandas/tests/indexes/categorical/test_formats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_string_categorical_index_repr(self):
7676

7777
assert repr(idx) == expected
7878

79-
# Emable Unicode option -----------------------------------------
79+
# Enable Unicode option -----------------------------------------
8080
with cf.option_context("display.unicode.east_asian_width", True):
8181

8282
# short

pandas/tests/indexes/datetimelike_/test_sort_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def test_sort_values_without_freq_periodindex(self, idx, expected):
295295
self.check_sort_values_without_freq(idx, expected)
296296

297297
def test_sort_values_without_freq_periodindex_nat(self):
298-
# doesnt quite fit into check_sort_values_without_freq
298+
# doesn't quite fit into check_sort_values_without_freq
299299
idx = PeriodIndex(["2011", "2013", "NaT", "2011"], name="pidx", freq="D")
300300
expected = PeriodIndex(["NaT", "2011", "2011", "2013"], name="pidx", freq="D")
301301

pandas/tests/indexes/datetimes/methods/test_insert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_insert_empty_preserves_freq(self, tz_naive_fixture):
4747
result = dti.insert(0, item)
4848
assert result.freq == dti.freq
4949

50-
# But not when we insert an item that doesnt conform to freq
50+
# But not when we insert an item that doesn't conform to freq
5151
dti = DatetimeIndex([], tz=tz, freq="W-THU")
5252
result = dti.insert(0, item)
5353
assert result.freq is None

pandas/tests/indexes/datetimes/test_timezones.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def test_dti_tz_localize_roundtrip(self, tz_aware_fixture):
465465
idx = date_range(start="2014-06-01", end="2014-08-30", freq="15T")
466466
tz = tz_aware_fixture
467467
localized = idx.tz_localize(tz)
468-
# cant localize a tz-aware object
468+
# can't localize a tz-aware object
469469
with pytest.raises(
470470
TypeError, match="Already tz-aware, use tz_convert to convert"
471471
):

pandas/tests/indexes/multi/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_constructor_mismatched_codes_levels(idx):
108108
def test_na_levels():
109109
# GH26408
110110
# test if codes are re-assigned value -1 for levels
111-
# with mising values (NaN, NaT, None)
111+
# with missing values (NaN, NaT, None)
112112
result = MultiIndex(
113113
levels=[[np.nan, None, pd.NaT, 128, 2]], codes=[[0, -1, 1, 2, 3, 4]]
114114
)

pandas/tests/indexes/period/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def test_get_indexer_mismatched_dtype(self):
464464
tm.assert_numpy_array_equal(result, expected)
465465

466466
def test_get_indexer_mismatched_dtype_different_length(self, non_comparable_idx):
467-
# without method we arent checking inequalities, so get all-missing
467+
# without method we aren't checking inequalities, so get all-missing
468468
# but do not raise
469469
dti = date_range("2016-01-01", periods=3)
470470
pi = dti.to_period("D")

pandas/tests/indexes/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass):
386386
@pytest.mark.parametrize("klass", [Index, TimedeltaIndex])
387387
def test_constructor_dtypes_timedelta(self, attr, klass):
388388
index = pd.timedelta_range("1 days", periods=5)
389-
index = index._with_freq(None) # wont be preserved by constructors
389+
index = index._with_freq(None) # won't be preserved by constructors
390390
dtype = index.dtype
391391

392392
values = getattr(index, attr)

pandas/tests/indexes/timedeltas/methods/test_insert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_insert_non_castable_str(self):
128128
tm.assert_index_equal(result, expected)
129129

130130
def test_insert_empty(self):
131-
# Corner case inserting with length zero doesnt raise IndexError
131+
# Corner case inserting with length zero doesn't raise IndexError
132132
# GH#33573 for freq preservation
133133
idx = timedelta_range("1 Day", periods=3)
134134
td = idx[0]

pandas/tests/indexes/timedeltas/test_setops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_intersection_bug_1708(self):
116116

117117
def test_intersection_equal(self, sort):
118118
# GH 24471 Test intersection outcome given the sort keyword
119-
# for equal indicies intersection should return the original index
119+
# for equal indices intersection should return the original index
120120
first = timedelta_range("1 day", periods=4, freq="h")
121121
second = timedelta_range("1 day", periods=4, freq="h")
122122
intersect = first.intersection(second, sort=sort)

pandas/tests/indexing/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def check_values(self, f, func, values=False):
136136
if f is None:
137137
return
138138
axes = f.axes
139-
indicies = itertools.product(*axes)
139+
indices = itertools.product(*axes)
140140

141-
for i in indicies:
141+
for i in indices:
142142
result = getattr(f, func)[i]
143143

144144
# check against values

pandas/tests/indexing/test_coercion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value
443443
assert expected.dtype == object
444444
tm.assert_index_equal(result, expected)
445445

446-
# mismatched tz --> cast to object (could reasonably cast to commom tz)
446+
# mismatched tz --> cast to object (could reasonably cast to common tz)
447447
ts = pd.Timestamp("2012-01-01", tz="Asia/Tokyo")
448448
result = obj.insert(1, ts)
449449
expected = obj.astype(object).insert(1, ts)

pandas/tests/indexing/test_iloc.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_iloc_setitem_ea_inplace(self, frame_or_series, box):
112112
assert obj.values.base is values.base and values.base is not None
113113

114114
def test_is_scalar_access(self):
115-
# GH#32085 index with duplicates doesnt matter for _is_scalar_access
115+
# GH#32085 index with duplicates doesn't matter for _is_scalar_access
116116
index = Index([1, 2, 1])
117117
ser = Series(range(3), index=index)
118118

@@ -739,18 +739,18 @@ def test_iloc_mask(self):
739739
accessor = getattr(df, method[1:])
740740
else:
741741
accessor = df
742-
ans = str(bin(accessor[mask]["nums"].sum()))
742+
answer = str(bin(accessor[mask]["nums"].sum()))
743743
except (ValueError, IndexingError, NotImplementedError) as e:
744-
ans = str(e)
744+
answer = str(e)
745745

746746
key = (
747747
idx,
748748
method,
749749
)
750750
r = expected.get(key)
751-
if r != ans:
751+
if r != answer:
752752
raise AssertionError(
753-
f"[{key}] does not match [{ans}], received [{r}]"
753+
f"[{key}] does not match [{answer}], received [{r}]"
754754
)
755755

756756
def test_iloc_non_unique_indexing(self):

0 commit comments

Comments
 (0)