Skip to content

Comma cleanup #36082

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 4 commits into from
Sep 5, 2020
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
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_reindex_with_same_tz(self):
"2010-01-02 00:00:00",
]
expected1 = DatetimeIndex(
expected_list1, dtype="datetime64[ns, UTC]", freq=None,
expected_list1, dtype="datetime64[ns, UTC]", freq=None
)
expected2 = np.array([0] + [-1] * 21 + [23], dtype=np.dtype("intp"))
tm.assert_index_equal(result1, expected1)
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 @@ -799,7 +799,7 @@ def test_dti_from_tzaware_datetime(self, tz):

@pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
def test_dti_tz_constructors(self, tzstr):
""" Test different DatetimeIndex constructions with timezone
"""Test different DatetimeIndex constructions with timezone
Follow-up of GH#4229
"""
arr = ["11/10/2005 08:00:00", "11/10/2005 09:00:00"]
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/multi/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,18 +741,18 @@ def test_raise_invalid_sortorder():

with pytest.raises(ValueError, match=r".* sortorder 2 with lexsort_depth 1.*"):
MultiIndex(
levels=levels, codes=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 2, 1]], sortorder=2,
levels=levels, codes=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 2, 1]], sortorder=2
)

with pytest.raises(ValueError, match=r".* sortorder 1 with lexsort_depth 0.*"):
MultiIndex(
levels=levels, codes=[[0, 0, 1, 0, 1, 1], [0, 1, 0, 2, 2, 1]], sortorder=1,
levels=levels, codes=[[0, 0, 1, 0, 1, 1], [0, 1, 0, 2, 2, 1]], sortorder=1
)


def test_datetimeindex():
idx1 = pd.DatetimeIndex(
["2013-04-01 9:00", "2013-04-02 9:00", "2013-04-03 9:00"] * 2, tz="Asia/Tokyo",
["2013-04-01 9:00", "2013-04-02 9:00", "2013-04-03 9:00"] * 2, tz="Asia/Tokyo"
)
idx2 = pd.date_range("2010/01/01", periods=6, freq="M", tz="US/Eastern")
idx = MultiIndex.from_arrays([idx1, idx2])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_isin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_isin_level_kwarg():
@pytest.mark.parametrize(
"labels,expected,level",
[
([("b", np.nan)], np.array([False, False, True]), None,),
([("b", np.nan)], np.array([False, False, True]), None),
([np.nan, "a"], np.array([True, True, False]), 0),
(["d", np.nan], np.array([False, True, True]), 1),
],
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 @@ -2426,7 +2426,7 @@ def test_index_with_tuple_bool(self):
# TODO: remove tupleize_cols=False once correct behaviour is restored
# TODO: also this op right now produces FutureWarning from numpy
idx = Index([("a", "b"), ("b", "c"), ("c", "a")], tupleize_cols=False)
result = idx == ("c", "a",)
result = idx == ("c", "a")
expected = np.array([False, False, True])
tm.assert_numpy_array_equal(result, expected)

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/timedeltas/test_scalar_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ def test_round(self):
"L",
t1a,
TimedeltaIndex(
["-1 days +00:00:00", "-2 days +23:58:58", "-2 days +23:57:56"],
["-1 days +00:00:00", "-2 days +23:58:58", "-2 days +23:57:56"]
),
),
(
"S",
t1a,
TimedeltaIndex(
["-1 days +00:00:00", "-2 days +23:58:58", "-2 days +23:57:56"],
["-1 days +00:00:00", "-2 days +23:58:58", "-2 days +23:57:56"]
),
),
("12T", t1c, TimedeltaIndex(["-1 days", "-1 days", "-1 days"],),),
("H", t1c, TimedeltaIndex(["-1 days", "-1 days", "-1 days"],),),
("12T", t1c, TimedeltaIndex(["-1 days", "-1 days", "-1 days"])),
("H", t1c, TimedeltaIndex(["-1 days", "-1 days", "-1 days"])),
("d", t1c, TimedeltaIndex([-1, -1, -1], unit="D")),
]:

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/test_searchsorted.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_searchsorted_different_argument_classes(self, klass):
tm.assert_numpy_array_equal(result, expected)

@pytest.mark.parametrize(
"arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2],
"arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2]
)
def test_searchsorted_invalid_argument_dtype(self, arg):
idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ def check_values(self, f, func, values=False):

tm.assert_almost_equal(result, expected)

def check_result(
self, method, key, typs=None, axes=None, fails=None,
):
def check_result(self, method, key, typs=None, axes=None, fails=None):
def _eq(axis, obj, key):
""" compare equal for these 2 keys """
axified = _axify(obj, key, axis)
Expand Down
18 changes: 6 additions & 12 deletions pandas/tests/indexing/test_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ def test_frame_loc_callable(self):
res = df.loc[lambda x: x.A > 2]
tm.assert_frame_equal(res, df.loc[df.A > 2])

res = df.loc[
lambda x: x.A > 2,
] # noqa: E231
tm.assert_frame_equal(res, df.loc[df.A > 2,]) # noqa: E231
res = df.loc[lambda x: x.A > 2] # noqa: E231
tm.assert_frame_equal(res, df.loc[df.A > 2]) # noqa: E231

res = df.loc[
lambda x: x.A > 2,
] # noqa: E231
tm.assert_frame_equal(res, df.loc[df.A > 2,]) # noqa: E231
res = df.loc[lambda x: x.A > 2] # noqa: E231
tm.assert_frame_equal(res, df.loc[df.A > 2]) # noqa: E231

res = df.loc[lambda x: x.B == "b", :]
tm.assert_frame_equal(res, df.loc[df.B == "b", :])
Expand Down Expand Up @@ -94,10 +90,8 @@ def test_frame_loc_callable_labels(self):
res = df.loc[lambda x: ["A", "C"]]
tm.assert_frame_equal(res, df.loc[["A", "C"]])

res = df.loc[
lambda x: ["A", "C"],
] # noqa: E231
tm.assert_frame_equal(res, df.loc[["A", "C"],]) # noqa: E231
res = df.loc[lambda x: ["A", "C"]] # noqa: E231
tm.assert_frame_equal(res, df.loc[["A", "C"]]) # noqa: E231

res = df.loc[lambda x: ["A", "C"], :]
tm.assert_frame_equal(res, df.loc[["A", "C"], :])
Expand Down
8 changes: 3 additions & 5 deletions pandas/tests/indexing/test_check_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_valid_input(indexer, expected):


@pytest.mark.parametrize(
"indexer", [[True, False, None], pd.array([True, False, None], dtype="boolean")],
"indexer", [[True, False, None], pd.array([True, False, None], dtype="boolean")]
)
def test_boolean_na_returns_indexer(indexer):
# https://github.com/pandas-dev/pandas/issues/31503
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_bool_raise_length(indexer):


@pytest.mark.parametrize(
"indexer", [[0, 1, None], pd.array([0, 1, pd.NA], dtype="Int64")],
"indexer", [[0, 1, None], pd.array([0, 1, pd.NA], dtype="Int64")]
)
def test_int_raise_missing_values(indexer):
array = np.array([1, 2, 3])
Expand Down Expand Up @@ -89,9 +89,7 @@ def test_raise_invalid_array_dtypes(indexer):
check_array_indexer(array, indexer)


@pytest.mark.parametrize(
"indexer", [None, Ellipsis, slice(0, 3), (None,)],
)
@pytest.mark.parametrize("indexer", [None, Ellipsis, slice(0, 3), (None,)])
def test_pass_through_non_array_likes(indexer):
array = np.array([1, 2, 3])

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 @@ -87,7 +87,7 @@ def _assert_setitem_series_conversion(
# tm.assert_series_equal(temp, expected_series)

@pytest.mark.parametrize(
"val,exp_dtype", [(1, object), (1.1, object), (1 + 1j, object), (True, object)],
"val,exp_dtype", [(1, object), (1.1, object), (1 + 1j, object), (True, object)]
)
def test_setitem_series_object(self, val, exp_dtype):
obj = pd.Series(list("abcd"))
Expand Down
14 changes: 4 additions & 10 deletions pandas/tests/indexing/test_floats.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ def test_scalar_with_mixed(self):
expected = 3
assert result == expected

@pytest.mark.parametrize(
"index_func", [tm.makeIntIndex, tm.makeRangeIndex],
)
@pytest.mark.parametrize("index_func", [tm.makeIntIndex, tm.makeRangeIndex])
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_scalar_integer(self, index_func, klass):

Expand Down Expand Up @@ -405,7 +403,7 @@ def test_slice_integer(self):

@pytest.mark.parametrize("l", [slice(2, 4.0), slice(2.0, 4), slice(2.0, 4.0)])
def test_integer_positional_indexing(self, l):
""" make sure that we are raising on positional indexing
"""make sure that we are raising on positional indexing
w.r.t. an integer index
"""
s = Series(range(2, 6), index=range(2, 6))
Expand All @@ -425,9 +423,7 @@ def test_integer_positional_indexing(self, l):
with pytest.raises(TypeError, match=msg):
s.iloc[l]

@pytest.mark.parametrize(
"index_func", [tm.makeIntIndex, tm.makeRangeIndex],
)
@pytest.mark.parametrize("index_func", [tm.makeIntIndex, tm.makeRangeIndex])
def test_slice_integer_frame_getitem(self, index_func):

# similar to above, but on the getitem dim (of a DataFrame)
Expand Down Expand Up @@ -486,9 +482,7 @@ def test_slice_integer_frame_getitem(self, index_func):
s[l]

@pytest.mark.parametrize("l", [slice(3.0, 4), slice(3, 4.0), slice(3.0, 4.0)])
@pytest.mark.parametrize(
"index_func", [tm.makeIntIndex, tm.makeRangeIndex],
)
@pytest.mark.parametrize("index_func", [tm.makeIntIndex, tm.makeRangeIndex])
def test_float_slice_getitem_with_integer_index_raises(self, l, index_func):

# similar to above, but on the getitem dim (of a DataFrame)
Expand Down