Skip to content

STYLE: Extending codespell to pandas/tests Part 2 #40332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ def test_setitem_corner(self, float_frame):
dm["foo"] = "bar"
assert dm["foo"].dtype == np.object_

dm["coercable"] = ["1", "2", "3"]
assert dm["coercable"].dtype == np.object_
dm["coercible"] = ["1", "2", "3"]
assert dm["coercible"].dtype == np.object_

def test_setitem_corner2(self):
data = {
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def test_setitem_intervals(self):
assert isinstance(ser.cat.categories, IntervalIndex)

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

# Thes goes through the Series constructor and so get inferred back
# These go through the Series constructor and so get inferred back
# to IntervalDtype
assert is_interval_dtype(df["C"])
assert is_interval_dtype(df["E"])

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

# they compare equal as Index
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_cov_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_corr_item_cache(self, using_array_manager):

_ = df.corr()

# Check that the corr didnt break link between ser and df
# Check that the corr didn't break link between ser and df
ser.values[0] = 99
assert df.loc[0, "A"] == 99
assert df["A"] is ser
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ class TestQuantileExtensionDtype:
pd.date_range("2016-01-01", periods=9, tz="US/Pacific"),
pytest.param(
pd.array(np.arange(9), dtype="Int64"),
marks=pytest.mark.xfail(reason="doesnt implement from_factorized"),
marks=pytest.mark.xfail(reason="doesn't implement from_factorized"),
),
pytest.param(
pd.array(np.arange(9), dtype="Float64"),
marks=pytest.mark.xfail(reason="doesnt implement from_factorized"),
marks=pytest.mark.xfail(reason="doesn't implement from_factorized"),
),
],
ids=lambda x: str(x.dtype),
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,8 +1439,8 @@ def test_categorical_replace_with_dict(self, replace_dict, final_data):

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

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

expected = DataFrame({"a": a, "b": b})
result = df.replace(replace_dict, 3)
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/frame/methods/test_reset_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def test_reset_index(self, float_frame):

# preserve column names
float_frame.columns.name = "columns"
resetted = float_frame.reset_index()
assert resetted.columns.name == "columns"
reset = float_frame.reset_index()
assert reset.columns.name == "columns"

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

# test resetting in place
df = float_frame.copy()
resetted = float_frame.reset_index()
reset = float_frame.reset_index()
return_value = df.reset_index(inplace=True)
assert return_value is None
tm.assert_frame_equal(df, resetted, check_names=False)
tm.assert_frame_equal(df, reset, check_names=False)

df = float_frame.reset_index().set_index(["index", "A", "B"])
rs = df.reset_index("A", drop=True)
Expand Down Expand Up @@ -224,11 +224,11 @@ def test_reset_index_right_dtype(self):
)
df = DataFrame(s1)

resetted = s1.reset_index()
assert resetted["time"].dtype == np.float64
reset = s1.reset_index()
assert reset["time"].dtype == np.float64

resetted = df.reset_index()
assert resetted["time"].dtype == np.float64
reset = df.reset_index()
assert reset["time"].dtype == np.float64

def test_reset_index_multiindex_col(self):
vals = np.random.randn(3, 3).astype(object)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_to_dict_of_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_to_dict_of_blocks_item_cache():

df._to_dict_of_blocks()

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_frame_values_with_tz(self):
)
tm.assert_numpy_array_equal(result, expected)

# two columns, homogenous
# two columns, homogeneous

df["B"] = df["A"]
result = df.values
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def test_subclassed_apply(self):
def check_row_subclass(row):
assert isinstance(row, tm.SubclassedSeries)

def strech(row):
def stretch(row):
if row["variable"] == "height":
row["value"] += 0.5
return row
Expand Down Expand Up @@ -547,7 +547,7 @@ def strech(row):
columns=["first", "last", "variable", "value"],
)

result = df.apply(lambda x: strech(x), axis=1)
result = df.apply(lambda x: stretch(x), axis=1)
assert isinstance(result, tm.SubclassedDataFrame)
tm.assert_frame_equal(result, expected)

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def test_agg_relabel_multiindex_column(


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


def test_agg_relabel_multiindex_duplicates():
# GH29422, add test for raises senario when getting duplicates
# GH29422, add test for raises scenario when getting duplicates
# GH28426, after this change, duplicates should also work if the relabelling is
# different
df = DataFrame(
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/groupby/test_libgroupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ def _check_cython_group_transform_cumulative(pd_op, np_op, dtype):
is_datetimelike = False

data = np.array([[1], [2], [3], [4]], dtype=dtype)
ans = np.zeros_like(data)
answer = np.zeros_like(data)

labels = np.array([0, 0, 0, 0], dtype=np.int64)
ngroups = 1
pd_op(ans, data, labels, ngroups, is_datetimelike)
pd_op(answer, data, labels, ngroups, is_datetimelike)

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


def test_cython_group_transform_cumsum(any_real_dtype):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/categorical/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_string_categorical_index_repr(self):

assert repr(idx) == expected

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

# short
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimelike_/test_sort_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def test_sort_values_without_freq_periodindex(self, idx, expected):
self.check_sort_values_without_freq(idx, expected)

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/methods/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_insert_empty_preserves_freq(self, tz_naive_fixture):
result = dti.insert(0, item)
assert result.freq == dti.freq

# But not when we insert an item that doesnt conform to freq
# But not when we insert an item that doesn't conform to freq
dti = DatetimeIndex([], tz=tz, freq="W-THU")
result = dti.insert(0, item)
assert result.freq is None
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def test_dti_tz_localize_roundtrip(self, tz_aware_fixture):
idx = date_range(start="2014-06-01", end="2014-08-30", freq="15T")
tz = tz_aware_fixture
localized = idx.tz_localize(tz)
# cant localize a tz-aware object
# can't localize a tz-aware object
with pytest.raises(
TypeError, match="Already tz-aware, use tz_convert to convert"
):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_constructor_mismatched_codes_levels(idx):
def test_na_levels():
# GH26408
# test if codes are re-assigned value -1 for levels
# with mising values (NaN, NaT, None)
# with missing values (NaN, NaT, None)
result = MultiIndex(
levels=[[np.nan, None, pd.NaT, 128, 2]], codes=[[0, -1, 1, 2, 3, 4]]
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/period/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_get_indexer_mismatched_dtype(self):
tm.assert_numpy_array_equal(result, expected)

def test_get_indexer_mismatched_dtype_different_length(self, non_comparable_idx):
# without method we arent checking inequalities, so get all-missing
# without method we aren't checking inequalities, so get all-missing
# but do not raise
dti = date_range("2016-01-01", periods=3)
pi = dti.to_period("D")
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass):
@pytest.mark.parametrize("klass", [Index, TimedeltaIndex])
def test_constructor_dtypes_timedelta(self, attr, klass):
index = pd.timedelta_range("1 days", periods=5)
index = index._with_freq(None) # wont be preserved by constructors
index = index._with_freq(None) # won't be preserved by constructors
dtype = index.dtype

values = getattr(index, attr)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/methods/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_insert_non_castable_str(self):
tm.assert_index_equal(result, expected)

def test_insert_empty(self):
# Corner case inserting with length zero doesnt raise IndexError
# Corner case inserting with length zero doesn't raise IndexError
# GH#33573 for freq preservation
idx = timedelta_range("1 Day", periods=3)
td = idx[0]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_intersection_bug_1708(self):

def test_intersection_equal(self, sort):
# GH 24471 Test intersection outcome given the sort keyword
# for equal indicies intersection should return the original index
# for equal indices intersection should return the original index
first = timedelta_range("1 day", periods=4, freq="h")
second = timedelta_range("1 day", periods=4, freq="h")
intersect = first.intersection(second, sort=sort)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def check_values(self, f, func, values=False):
if f is None:
return
axes = f.axes
indicies = itertools.product(*axes)
indices = itertools.product(*axes)

for i in indicies:
for i in indices:
result = getattr(f, func)[i]

# check against values
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value
assert expected.dtype == object
tm.assert_index_equal(result, expected)

# mismatched tz --> cast to object (could reasonably cast to commom tz)
# mismatched tz --> cast to object (could reasonably cast to common tz)
ts = pd.Timestamp("2012-01-01", tz="Asia/Tokyo")
result = obj.insert(1, ts)
expected = obj.astype(object).insert(1, ts)
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_iloc_setitem_ea_inplace(self, frame_or_series, box):
assert obj.values.base is values.base and values.base is not None

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

Expand Down Expand Up @@ -739,18 +739,18 @@ def test_iloc_mask(self):
accessor = getattr(df, method[1:])
else:
accessor = df
ans = str(bin(accessor[mask]["nums"].sum()))
answer = str(bin(accessor[mask]["nums"].sum()))
except (ValueError, IndexingError, NotImplementedError) as e:
ans = str(e)
answer = str(e)

key = (
idx,
method,
)
r = expected.get(key)
if r != ans:
if r != answer:
raise AssertionError(
f"[{key}] does not match [{ans}], received [{r}]"
f"[{key}] does not match [{answer}], received [{r}]"
)

def test_iloc_non_unique_indexing(self):
Expand Down