Skip to content

Commit 2a5e3cc

Browse files
Comma cleanup (#36168)
1 parent 773f64d commit 2a5e3cc

11 files changed

+34
-57
lines changed

pandas/tests/indexing/test_iloc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_is_scalar_access(self):
5656
assert ser.iloc._is_scalar_access((1,))
5757

5858
df = ser.to_frame()
59-
assert df.iloc._is_scalar_access((1, 0,))
59+
assert df.iloc._is_scalar_access((1, 0))
6060

6161
def test_iloc_exceeds_bounds(self):
6262

pandas/tests/indexing/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ def test_extension_array_cross_section():
10041004
def test_extension_array_cross_section_converts():
10051005
# all numeric columns -> numeric series
10061006
df = pd.DataFrame(
1007-
{"A": pd.array([1, 2], dtype="Int64"), "B": np.array([1, 2])}, index=["a", "b"],
1007+
{"A": pd.array([1, 2], dtype="Int64"), "B": np.array([1, 2])}, index=["a", "b"]
10081008
)
10091009
result = df.loc["a"]
10101010
expected = pd.Series([1, 1], dtype="Int64", index=["A", "B"], name="a")

pandas/tests/indexing/test_loc.py

+12-21
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ def test_loc_getitem_label_out_of_range(self):
2929

3030
# out of range label
3131
self.check_result(
32-
"loc", "f", typs=["ints", "uints", "labels", "mixed", "ts"], fails=KeyError,
32+
"loc", "f", typs=["ints", "uints", "labels", "mixed", "ts"], fails=KeyError
3333
)
3434
self.check_result("loc", "f", typs=["floats"], fails=KeyError)
3535
self.check_result("loc", "f", typs=["floats"], fails=KeyError)
36-
self.check_result(
37-
"loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError,
38-
)
36+
self.check_result("loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError)
3937
self.check_result("loc", 20, typs=["labels"], fails=KeyError)
4038
self.check_result("loc", 20, typs=["ts"], axes=0, fails=KeyError)
4139
self.check_result("loc", 20, typs=["floats"], axes=0, fails=KeyError)
@@ -46,26 +44,24 @@ def test_loc_getitem_label_list(self):
4644
pass
4745

4846
def test_loc_getitem_label_list_with_missing(self):
47+
self.check_result("loc", [0, 1, 2], typs=["empty"], fails=KeyError)
4948
self.check_result(
50-
"loc", [0, 1, 2], typs=["empty"], fails=KeyError,
51-
)
52-
self.check_result(
53-
"loc", [0, 2, 10], typs=["ints", "uints", "floats"], axes=0, fails=KeyError,
49+
"loc", [0, 2, 10], typs=["ints", "uints", "floats"], axes=0, fails=KeyError
5450
)
5551

5652
self.check_result(
57-
"loc", [3, 6, 7], typs=["ints", "uints", "floats"], axes=1, fails=KeyError,
53+
"loc", [3, 6, 7], typs=["ints", "uints", "floats"], axes=1, fails=KeyError
5854
)
5955

6056
# GH 17758 - MultiIndex and missing keys
6157
self.check_result(
62-
"loc", [(1, 3), (1, 4), (2, 5)], typs=["multi"], axes=0, fails=KeyError,
58+
"loc", [(1, 3), (1, 4), (2, 5)], typs=["multi"], axes=0, fails=KeyError
6359
)
6460

6561
def test_loc_getitem_label_list_fails(self):
6662
# fails
6763
self.check_result(
68-
"loc", [20, 30, 40], typs=["ints", "uints"], axes=1, fails=KeyError,
64+
"loc", [20, 30, 40], typs=["ints", "uints"], axes=1, fails=KeyError
6965
)
7066

7167
def test_loc_getitem_label_array_like(self):
@@ -95,18 +91,14 @@ def test_loc_getitem_label_slice(self):
9591
)
9692

9793
self.check_result(
98-
"loc", slice("20130102", "20130104"), typs=["ts"], axes=1, fails=TypeError,
94+
"loc", slice("20130102", "20130104"), typs=["ts"], axes=1, fails=TypeError
9995
)
10096

101-
self.check_result(
102-
"loc", slice(2, 8), typs=["mixed"], axes=0, fails=TypeError,
103-
)
104-
self.check_result(
105-
"loc", slice(2, 8), typs=["mixed"], axes=1, fails=KeyError,
106-
)
97+
self.check_result("loc", slice(2, 8), typs=["mixed"], axes=0, fails=TypeError)
98+
self.check_result("loc", slice(2, 8), typs=["mixed"], axes=1, fails=KeyError)
10799

108100
self.check_result(
109-
"loc", slice(2, 4, 2), typs=["mixed"], axes=0, fails=TypeError,
101+
"loc", slice(2, 4, 2), typs=["mixed"], axes=0, fails=TypeError
110102
)
111103

112104
def test_setitem_from_duplicate_axis(self):
@@ -669,8 +661,7 @@ def test_loc_setitem_with_scalar_index(self, indexer, value):
669661
(1, ["A", "B", "C"]),
670662
np.array([7, 8, 9], dtype=np.int64),
671663
pd.DataFrame(
672-
[[1, 2, np.nan], [7, 8, 9], [5, 6, np.nan]],
673-
columns=["A", "B", "C"],
664+
[[1, 2, np.nan], [7, 8, 9], [5, 6, np.nan]], columns=["A", "B", "C"]
674665
),
675666
),
676667
(

pandas/tests/internals/test_internals.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -892,16 +892,16 @@ def assert_reindex_indexer_is_ok(mgr, axis, new_labels, indexer, fill_value):
892892
fill_value,
893893
)
894894
assert_reindex_indexer_is_ok(
895-
mgr, ax, mgr.axes[ax][::-1], np.arange(mgr.shape[ax]), fill_value,
895+
mgr, ax, mgr.axes[ax][::-1], np.arange(mgr.shape[ax]), fill_value
896896
)
897897
assert_reindex_indexer_is_ok(
898-
mgr, ax, mgr.axes[ax], np.arange(mgr.shape[ax])[::-1], fill_value,
898+
mgr, ax, mgr.axes[ax], np.arange(mgr.shape[ax])[::-1], fill_value
899899
)
900900
assert_reindex_indexer_is_ok(
901901
mgr, ax, pd.Index(["foo", "bar", "baz"]), [0, 0, 0], fill_value
902902
)
903903
assert_reindex_indexer_is_ok(
904-
mgr, ax, pd.Index(["foo", "bar", "baz"]), [-1, 0, -1], fill_value,
904+
mgr, ax, pd.Index(["foo", "bar", "baz"]), [-1, 0, -1], fill_value
905905
)
906906
assert_reindex_indexer_is_ok(
907907
mgr,
@@ -913,7 +913,7 @@ def assert_reindex_indexer_is_ok(mgr, axis, new_labels, indexer, fill_value):
913913

914914
if mgr.shape[ax] >= 3:
915915
assert_reindex_indexer_is_ok(
916-
mgr, ax, pd.Index(["foo", "bar", "baz"]), [0, 1, 2], fill_value,
916+
mgr, ax, pd.Index(["foo", "bar", "baz"]), [0, 1, 2], fill_value
917917
)
918918

919919

pandas/tests/io/formats/test_css.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ def test_css_side_shorthands(shorthand, expansions):
9999
top, right, bottom, left = expansions
100100

101101
assert_resolves(
102-
f"{shorthand}: 1pt", {top: "1pt", right: "1pt", bottom: "1pt", left: "1pt"},
102+
f"{shorthand}: 1pt", {top: "1pt", right: "1pt", bottom: "1pt", left: "1pt"}
103103
)
104104

105105
assert_resolves(
106-
f"{shorthand}: 1pt 4pt", {top: "1pt", right: "4pt", bottom: "1pt", left: "4pt"},
106+
f"{shorthand}: 1pt 4pt", {top: "1pt", right: "4pt", bottom: "1pt", left: "4pt"}
107107
)
108108

109109
assert_resolves(
@@ -189,9 +189,7 @@ def test_css_absolute_font_size(size, relative_to, resolved):
189189
inherited = None
190190
else:
191191
inherited = {"font-size": relative_to}
192-
assert_resolves(
193-
f"font-size: {size}", {"font-size": resolved}, inherited=inherited,
194-
)
192+
assert_resolves(f"font-size: {size}", {"font-size": resolved}, inherited=inherited)
195193

196194

197195
@pytest.mark.parametrize(
@@ -225,6 +223,4 @@ def test_css_relative_font_size(size, relative_to, resolved):
225223
inherited = None
226224
else:
227225
inherited = {"font-size": relative_to}
228-
assert_resolves(
229-
f"font-size: {size}", {"font-size": resolved}, inherited=inherited,
230-
)
226+
assert_resolves(f"font-size: {size}", {"font-size": resolved}, inherited=inherited)

pandas/tests/io/formats/test_info.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def test_info_memory_usage():
299299
DataFrame(1, index=["a"], columns=["A"]).memory_usage(index=True)
300300
DataFrame(1, index=["a"], columns=["A"]).index.nbytes
301301
df = DataFrame(
302-
data=1, index=MultiIndex.from_product([["a"], range(1000)]), columns=["A"],
302+
data=1, index=MultiIndex.from_product([["a"], range(1000)]), columns=["A"]
303303
)
304304
df.index.nbytes
305305
df.memory_usage(index=True)
@@ -336,7 +336,7 @@ def test_info_memory_usage_deep_pypy():
336336
@pytest.mark.skipif(PYPY, reason="PyPy getsizeof() fails by design")
337337
def test_usage_via_getsizeof():
338338
df = DataFrame(
339-
data=1, index=MultiIndex.from_product([["a"], range(1000)]), columns=["A"],
339+
data=1, index=MultiIndex.from_product([["a"], range(1000)]), columns=["A"]
340340
)
341341
mem = df.memory_usage(deep=True).sum()
342342
# sys.getsizeof will call the .memory_usage with
@@ -359,16 +359,14 @@ def test_info_memory_usage_qualified():
359359

360360
buf = StringIO()
361361
df = DataFrame(
362-
1, columns=list("ab"), index=MultiIndex.from_product([range(3), range(3)]),
362+
1, columns=list("ab"), index=MultiIndex.from_product([range(3), range(3)])
363363
)
364364
df.info(buf=buf)
365365
assert "+" not in buf.getvalue()
366366

367367
buf = StringIO()
368368
df = DataFrame(
369-
1,
370-
columns=list("ab"),
371-
index=MultiIndex.from_product([range(3), ["foo", "bar"]]),
369+
1, columns=list("ab"), index=MultiIndex.from_product([range(3), ["foo", "bar"]])
372370
)
373371
df.info(buf=buf)
374372
assert "+" in buf.getvalue()
@@ -384,7 +382,7 @@ def memory_usage(f):
384382
N = 100
385383
M = len(uppercase)
386384
index = MultiIndex.from_product(
387-
[list(uppercase), date_range("20160101", periods=N)], names=["id", "date"],
385+
[list(uppercase), date_range("20160101", periods=N)], names=["id", "date"]
388386
)
389387
df = DataFrame({"value": np.random.randn(N * M)}, index=index)
390388

pandas/tests/io/json/test_compression.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_with_s3_url(compression, s3_resource, s3so):
4545
s3_resource.Bucket("pandas-test").put_object(Key="test-1", Body=f)
4646

4747
roundtripped_df = pd.read_json(
48-
"s3://pandas-test/test-1", compression=compression, storage_options=s3so,
48+
"s3://pandas-test/test-1", compression=compression, storage_options=s3so
4949
)
5050
tm.assert_frame_equal(df, roundtripped_df)
5151

pandas/tests/io/json/test_pandas.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,7 @@ def test_reconstruction_index(self):
745745

746746
def test_path(self, float_frame, int_frame, datetime_frame):
747747
with tm.ensure_clean("test.json") as path:
748-
for df in [
749-
float_frame,
750-
int_frame,
751-
datetime_frame,
752-
]:
748+
for df in [float_frame, int_frame, datetime_frame]:
753749
df.to_json(path)
754750
read_json(path)
755751

@@ -1706,9 +1702,7 @@ def test_to_s3(self, s3_resource, s3so):
17061702
# GH 28375
17071703
mock_bucket_name, target_file = "pandas-test", "test.json"
17081704
df = DataFrame({"x": [1, 2, 3], "y": [2, 4, 6]})
1709-
df.to_json(
1710-
f"s3://{mock_bucket_name}/{target_file}", storage_options=s3so,
1711-
)
1705+
df.to_json(f"s3://{mock_bucket_name}/{target_file}", storage_options=s3so)
17121706
timeout = 5
17131707
while True:
17141708
if target_file in (

pandas/tests/io/parser/test_c_parser_only.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,7 @@ def test_1000_sep_with_decimal(
646646
tm.assert_frame_equal(result, expected)
647647

648648

649-
@pytest.mark.parametrize(
650-
"float_precision", [None, "high", "round_trip"],
651-
)
649+
@pytest.mark.parametrize("float_precision", [None, "high", "round_trip"])
652650
@pytest.mark.parametrize(
653651
"value,expected",
654652
[

pandas/tests/io/parser/test_parse_dates.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ def test_parse_timezone(all_parsers):
14391439
end="2018-01-04 09:05:00",
14401440
freq="1min",
14411441
tz=pytz.FixedOffset(540),
1442-
),
1442+
)
14431443
),
14441444
freq=None,
14451445
)
@@ -1553,5 +1553,5 @@ def test_missing_parse_dates_column_raises(
15531553
msg = f"Missing column provided to 'parse_dates': '{missing_cols}'"
15541554
with pytest.raises(ValueError, match=msg):
15551555
parser.read_csv(
1556-
content, sep=",", names=names, usecols=usecols, parse_dates=parse_dates,
1556+
content, sep=",", names=names, usecols=usecols, parse_dates=parse_dates
15571557
)

pandas/tests/io/parser/test_usecols.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_usecols_with_whitespace(all_parsers):
199199
# Column selection by index.
200200
([0, 1], DataFrame(data=[[1000, 2000], [4000, 5000]], columns=["2", "0"])),
201201
# Column selection by name.
202-
(["0", "1"], DataFrame(data=[[2000, 3000], [5000, 6000]], columns=["0", "1"]),),
202+
(["0", "1"], DataFrame(data=[[2000, 3000], [5000, 6000]], columns=["0", "1"])),
203203
],
204204
)
205205
def test_usecols_with_integer_like_header(all_parsers, usecols, expected):

0 commit comments

Comments
 (0)