Skip to content

Issue35925 Remove trailing commas #35996

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 10 commits into from
Aug 31, 2020
2 changes: 1 addition & 1 deletion pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ def test_multilevel_index_loc_order(self, dim, keys, expected):
# GH 22797
# Try to respect order of keys given for MultiIndex.loc
kwargs = {dim: [["c", "a", "a", "b", "b"], [1, 1, 2, 1, 2]]}
df = pd.DataFrame(np.arange(25).reshape(5, 5), **kwargs,)
df = pd.DataFrame(np.arange(25).reshape(5, 5), **kwargs)
exp_index = MultiIndex.from_arrays(expected)
if dim == "index":
res = df.loc[keys, :]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_nansum(self, skipna):

def test_nanmean(self, skipna):
self.check_funs(
nanops.nanmean, np.mean, skipna, allow_obj=False, allow_date=False,
nanops.nanmean, np.mean, skipna, allow_obj=False, allow_date=False
)

def test_nanmean_overflow(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_rolling_apply_consistency(

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message=".*(empty slice|0 for slice).*", category=RuntimeWarning,
"ignore", message=".*(empty slice|0 for slice).*", category=RuntimeWarning
)
# test consistency between rolling_xyz() and either (a)
# rolling_apply of Series.xyz(), or (b) rolling_apply of
Expand All @@ -107,7 +107,7 @@ def test_rolling_apply_consistency(
functions = no_nan_functions + base_functions
for (f, require_min_periods, name) in functions:
rolling_f = getattr(
x.rolling(window=window, center=center, min_periods=min_periods), name,
x.rolling(window=window, center=center, min_periods=min_periods), name
)

if (
Expand Down Expand Up @@ -492,7 +492,7 @@ def test_moment_functions_zero_length_pairwise():
df2["a"] = df2["a"].astype("float64")

df1_expected = DataFrame(
index=pd.MultiIndex.from_product([df1.index, df1.columns]), columns=Index([]),
index=pd.MultiIndex.from_product([df1.index, df1.columns]), columns=Index([])
)
df2_expected = DataFrame(
index=pd.MultiIndex.from_product(
Expand Down Expand Up @@ -635,7 +635,7 @@ def test_rolling_consistency(consistency_data, window, min_periods, center):
# with empty/0-length Series/DataFrames
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message=".*(empty slice|0 for slice).*", category=RuntimeWarning,
"ignore", message=".*(empty slice|0 for slice).*", category=RuntimeWarning
)

# test consistency between different rolling_* moments
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/window/moments/test_moments_ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def simple_wma(s, w):
(s1, True, True, [(1.0 - alpha), np.nan, 1.0]),
(s1, False, False, [(1.0 - alpha) ** 2, np.nan, alpha]),
(s1, False, True, [(1.0 - alpha), np.nan, alpha]),
(s2, True, False, [np.nan, (1.0 - alpha) ** 3, np.nan, np.nan, 1.0, np.nan],),
(s2, True, False, [np.nan, (1.0 - alpha) ** 3, np.nan, np.nan, 1.0, np.nan]),
(s2, True, True, [np.nan, (1.0 - alpha), np.nan, np.nan, 1.0, np.nan]),
(
s2,
Expand All @@ -95,7 +95,7 @@ def simple_wma(s, w):
alpha * ((1.0 - alpha) ** 2 + alpha),
],
),
(s3, False, True, [(1.0 - alpha) ** 2, np.nan, (1.0 - alpha) * alpha, alpha],),
(s3, False, True, [(1.0 - alpha) ** 2, np.nan, (1.0 - alpha) * alpha, alpha]),
]:
expected = simple_wma(s, Series(w))
result = s.ewm(com=com, adjust=adjust, ignore_na=ignore_na).mean()
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/window/moments/test_moments_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ def get_result(obj, window, min_periods=None, center=False):

series_xp = (
get_result(
series.reindex(list(series.index) + s), window=25, min_periods=minp,
series.reindex(list(series.index) + s), window=25, min_periods=minp
)
.shift(-12)
.reindex(series.index)
)
frame_xp = (
get_result(
frame.reindex(list(frame.index) + s), window=25, min_periods=minp,
frame.reindex(list(frame.index) + s), window=25, min_periods=minp
)
.shift(-12)
.reindex(frame.index)
Expand All @@ -169,14 +169,14 @@ def get_result(obj, window, min_periods=None, center=False):
else:
series_xp = (
get_result(
series.reindex(list(series.index) + s), window=25, min_periods=0,
series.reindex(list(series.index) + s), window=25, min_periods=0
)
.shift(-12)
.reindex(series.index)
)
frame_xp = (
get_result(
frame.reindex(list(frame.index) + s), window=25, min_periods=0,
frame.reindex(list(frame.index) + s), window=25, min_periods=0
)
.shift(-12)
.reindex(frame.index)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/window/test_base_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def get_window_bounds(self, num_values, min_periods, center, closed):
@pytest.mark.parametrize(
"func,np_func,expected,np_kwargs",
[
("count", len, [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.0, np.nan], {},),
("min", np.min, [0.0, 1.0, 2.0, 3.0, 4.0, 6.0, 6.0, 7.0, 8.0, np.nan], {},),
("count", len, [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.0, np.nan], {}),
("min", np.min, [0.0, 1.0, 2.0, 3.0, 4.0, 6.0, 6.0, 7.0, 8.0, np.nan], {}),
(
"max",
np.max,
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_rolling_forward_skewness(constructor):
@pytest.mark.parametrize(
"func,expected",
[
("cov", [2.0, 2.0, 2.0, 97.0, 2.0, -93.0, 2.0, 2.0, np.nan, np.nan],),
("cov", [2.0, 2.0, 2.0, 97.0, 2.0, -93.0, 2.0, 2.0, np.nan, np.nan]),
(
"corr",
[
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/window/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_cov_mulittindex(self):

columns = MultiIndex.from_product([list("ab"), list("xy"), list("AB")])
index = range(3)
df = DataFrame(np.arange(24).reshape(3, 8), index=index, columns=columns,)
df = DataFrame(np.arange(24).reshape(3, 8), index=index, columns=columns)

result = df.ewm(alpha=0.1).cov()

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/window/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_constructor_with_timedelta_window(window):
# GH 15440
n = 10
df = DataFrame(
{"value": np.arange(n)}, index=pd.date_range("2015-12-24", periods=n, freq="D"),
{"value": np.arange(n)}, index=pd.date_range("2015-12-24", periods=n, freq="D")
)
expected_data = np.append([0.0, 1.0], np.arange(3.0, 27.0, 3))

Expand All @@ -92,7 +92,7 @@ def test_constructor_timedelta_window_and_minperiods(window, raw):
# GH 15305
n = 10
df = DataFrame(
{"value": np.arange(n)}, index=pd.date_range("2017-08-08", periods=n, freq="D"),
{"value": np.arange(n)}, index=pd.date_range("2017-08-08", periods=n, freq="D")
)
expected = DataFrame(
{"value": np.append([np.NaN, 1.0], np.arange(3.0, 27.0, 3))},
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_closed_one_entry(func):
def test_closed_one_entry_groupby(func):
# GH24718
ser = pd.DataFrame(
data={"A": [1, 1, 2], "B": [3, 2, 1]}, index=pd.date_range("2000", periods=3),
data={"A": [1, 1, 2], "B": [3, 2, 1]}, index=pd.date_range("2000", periods=3)
)
result = getattr(
ser.groupby("A", sort=False)["B"].rolling("10D", closed="left"), func
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_closed_one_entry_groupby(func):
def test_closed_min_max_datetime(input_dtype, func, closed, expected):
# see gh-21704
ser = pd.Series(
data=np.arange(10).astype(input_dtype), index=pd.date_range("2000", periods=10),
data=np.arange(10).astype(input_dtype), index=pd.date_range("2000", periods=10)
)

result = getattr(ser.rolling("3D", closed=closed), func)()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def is_superperiod(source, target) -> bool:


def _maybe_coerce_freq(code) -> str:
""" we might need to coerce a code to a rule_code
"""we might need to coerce a code to a rule_code
and uppercase it

Parameters
Expand Down
4 changes: 2 additions & 2 deletions pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ def skip_if_no(package: str, min_version: Optional[str] = None):
is_platform_windows(), reason="not used on win32"
)
skip_if_has_locale = pytest.mark.skipif(
_skip_if_has_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}",
_skip_if_has_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}"
)
skip_if_not_us_locale = pytest.mark.skipif(
_skip_if_not_us_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}",
_skip_if_not_us_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}"
)
skip_if_no_scipy = pytest.mark.skipif(
_skip_if_no_scipy(), reason="Missing SciPy requirement"
Expand Down