Skip to content

Commit 214e04f

Browse files
committed
upgrade version of 'black'
1 parent 5e3623c commit 214e04f

File tree

23 files changed

+64
-64
lines changed

23 files changed

+64
-64
lines changed

asv_bench/benchmarks/arithmetic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def setup(self, op):
125125
arr1 = np.random.randn(n_rows, int(n_cols / 2)).astype("f8")
126126
arr2 = np.random.randn(n_rows, int(n_cols / 2)).astype("f4")
127127
df = pd.concat(
128-
[pd.DataFrame(arr1), pd.DataFrame(arr2)], axis=1, ignore_index=True,
128+
[pd.DataFrame(arr1), pd.DataFrame(arr2)], axis=1, ignore_index=True
129129
)
130130
# should already be the case, but just to be sure
131131
df._consolidate_inplace()

doc/make.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def main():
286286

287287
joined = ",".join(cmds)
288288
argparser = argparse.ArgumentParser(
289-
description="pandas documentation builder", epilog=f"Commands: {joined}",
289+
description="pandas documentation builder", epilog=f"Commands: {joined}"
290290
)
291291

292292
joined = ", ".join(cmds)

doc/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308

309309
for method in methods:
310310
# ... and each of its public methods
311-
moved_api_pages.append((f"{old}.{method}", f"{new}.{method}",))
311+
moved_api_pages.append((f"{old}.{method}", f"{new}.{method}"))
312312

313313
if pattern is None:
314314
html_additional_pages = {

pandas/_vendored/typing_extensions.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2116,8 +2116,7 @@ def __init_subclass__(cls, *args, **kwargs):
21162116
raise TypeError(f"Cannot subclass {cls.__module__}.Annotated")
21172117

21182118
def _strip_annotations(t):
2119-
"""Strips the annotations from a given type.
2120-
"""
2119+
"""Strips the annotations from a given type."""
21212120
if isinstance(t, _AnnotatedAlias):
21222121
return _strip_annotations(t.__origin__)
21232122
if isinstance(t, typing._GenericAlias):

pandas/core/aggregation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def validate_func_kwargs(
387387

388388

389389
def transform(
390-
obj: FrameOrSeries, func: AggFuncType, axis: Axis, *args, **kwargs,
390+
obj: FrameOrSeries, func: AggFuncType, axis: Axis, *args, **kwargs
391391
) -> FrameOrSeries:
392392
"""
393393
Transform a DataFrame or Series

pandas/core/algorithms.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1023,11 +1023,10 @@ def checked_add_with_arr(arr, b, arr_mask=None, b_mask=None):
10231023
to_raise = ((np.iinfo(np.int64).max - b2 < arr) & not_nan).any()
10241024
else:
10251025
to_raise = (
1026-
((np.iinfo(np.int64).max - b2[mask1] < arr[mask1]) & not_nan[mask1]).any()
1027-
or (
1028-
(np.iinfo(np.int64).min - b2[mask2] > arr[mask2]) & not_nan[mask2]
1029-
).any()
1030-
)
1026+
(np.iinfo(np.int64).max - b2[mask1] < arr[mask1]) & not_nan[mask1]
1027+
).any() or (
1028+
(np.iinfo(np.int64).min - b2[mask2] > arr[mask2]) & not_nan[mask2]
1029+
).any()
10311030

10321031
if to_raise:
10331032
raise OverflowError("Overflow in int64 addition")

pandas/core/array_algos/replace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def compare_or_regex_search(
20-
a: ArrayLike, b: Union[Scalar, Pattern], regex: bool, mask: ArrayLike,
20+
a: ArrayLike, b: Union[Scalar, Pattern], regex: bool, mask: ArrayLike
2121
) -> Union[ArrayLike, bool]:
2222
"""
2323
Compare two array_like inputs of the same shape or two scalar values

pandas/core/frame.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,7 @@ def __init__(
449449
if isinstance(data, BlockManager):
450450
if index is None and columns is None and dtype is None and copy is False:
451451
# GH#33357 fastpath
452-
NDFrame.__init__(
453-
self, data,
454-
)
452+
NDFrame.__init__(self, data)
455453
return
456454

457455
mgr = self._init_mgr(
@@ -5747,7 +5745,7 @@ def nsmallest(self, n, columns, keep="first") -> DataFrame:
57475745
population GDP alpha-2
57485746
Tuvalu 11300 38 TV
57495747
Anguilla 11300 311 AI
5750-
Iceland 337000 17036 IS
5748+
Iceland 337000 17036 IS
57515749
57525750
When using ``keep='last'``, ties are resolved in reverse order:
57535751
@@ -7142,7 +7140,7 @@ def unstack(self, level=-1, fill_value=None):
71427140

71437141
return unstack(self, level, fill_value)
71447142

7145-
@Appender(_shared_docs["melt"] % dict(caller="df.melt(", other="melt",))
7143+
@Appender(_shared_docs["melt"] % dict(caller="df.melt(", other="melt"))
71467144
def melt(
71477145
self,
71487146
id_vars=None,
@@ -8624,7 +8622,7 @@ def blk_func(values):
86248622
# After possibly _get_data and transposing, we are now in the
86258623
# simple case where we can use BlockManager.reduce
86268624
res = df._mgr.reduce(blk_func)
8627-
out = df._constructor(res,).iloc[0].rename(None)
8625+
out = df._constructor(res).iloc[0].rename(None)
86288626
if out_dtype is not None:
86298627
out = out.astype(out_dtype)
86308628
if axis == 0 and is_object_dtype(out.dtype):

pandas/core/series.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
199199
# Constructors
200200

201201
def __init__(
202-
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False,
202+
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False
203203
):
204204

205205
if (
@@ -209,9 +209,7 @@ def __init__(
209209
and copy is False
210210
):
211211
# GH#33357 called with just the SingleBlockManager
212-
NDFrame.__init__(
213-
self, data,
214-
)
212+
NDFrame.__init__(self, data)
215213
self.name = name
216214
return
217215

@@ -331,7 +329,8 @@ def __init__(
331329
data = SingleBlockManager.from_array(data, index)
332330

333331
generic.NDFrame.__init__(
334-
self, data,
332+
self,
333+
data,
335334
)
336335
self.name = name
337336
self._set_axis(0, index, fastpath=True)

pandas/core/sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_indexer_indexer(
7272
)
7373
elif isinstance(target, ABCMultiIndex):
7474
indexer = lexsort_indexer(
75-
target._get_codes_for_sorting(), orders=ascending, na_position=na_position,
75+
target._get_codes_for_sorting(), orders=ascending, na_position=na_position
7676
)
7777
else:
7878
# Check monotonic-ness before sort an index (GH 11080)

pandas/core/util/numba_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def set_use_numba(enable: bool = False) -> None:
2525

2626

2727
def get_jit_arguments(
28-
engine_kwargs: Optional[Dict[str, bool]] = None, kwargs: Optional[Dict] = None,
28+
engine_kwargs: Optional[Dict[str, bool]] = None, kwargs: Optional[Dict] = None
2929
) -> Tuple[bool, bool, bool]:
3030
"""
3131
Return arguments to pass to numba.JIT, falling back on pandas default JIT settings.

pandas/io/formats/format.py

-4
Original file line numberDiff line numberDiff line change
@@ -1285,10 +1285,6 @@ def _format(x):
12851285

12861286

12871287
class FloatArrayFormatter(GenericArrayFormatter):
1288-
"""
1289-
1290-
"""
1291-
12921288
def __init__(self, *args, **kwargs):
12931289
super().__init__(*args, **kwargs)
12941290

pandas/io/formats/info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def _verbose_repr(
511511
)
512512

513513
_display_counts_and_dtypes(
514-
lines, ids, dtypes, show_counts, count_configs, space_dtype,
514+
lines, ids, dtypes, show_counts, count_configs, space_dtype
515515
)
516516

517517
def _non_verbose_repr(self, lines: List[str], ids: "Index") -> None:

pandas/io/formats/latex.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def __init__(
4141
self.multirow = multirow
4242
self.clinebuf: List[List[int]] = []
4343
self.strcols = self._get_strcols()
44-
self.strrows: List[List[str]] = (
45-
list(zip(*self.strcols)) # type: ignore[arg-type]
46-
)
44+
self.strrows: List[List[str]] = list(
45+
zip(*self.strcols)
46+
) # type: ignore[arg-type]
4747

4848
def get_strrow(self, row_num: int) -> str:
4949
"""Get string representation of the row."""

pandas/tests/arrays/sparse/test_array.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ def test_constructor_inferred_fill_value(self, data, fill_value):
193193
assert result == fill_value
194194

195195
@pytest.mark.parametrize("format", ["coo", "csc", "csr"])
196-
@pytest.mark.parametrize(
197-
"size", [0, 10],
198-
)
196+
@pytest.mark.parametrize("size", [0, 10])
199197
@td.skip_if_no_scipy
200198
def test_from_spmatrix(self, size, format):
201199
import scipy.sparse
@@ -696,14 +694,17 @@ def test_getslice_tuple(self):
696694
res = sparse[
697695
4:,
698696
] # noqa: E231
699-
exp = SparseArray(dense[4:,]) # noqa: E231
697+
exp = SparseArray(np.array([0, 5, np.nan, np.nan, 0]))
700698
tm.assert_sp_array_equal(res, exp)
701699

702700
sparse = SparseArray(dense, fill_value=0)
703701
res = sparse[
704702
4:,
705703
] # noqa: E231
706-
exp = SparseArray(dense[4:,], fill_value=0) # noqa: E231
704+
exp = SparseArray(
705+
np.array([0, 5, np.nan, np.nan, 0]),
706+
fill_value=0,
707+
) # noqa: E231
707708
tm.assert_sp_array_equal(res, exp)
708709

709710
msg = "too many indices for array"

pandas/tests/frame/test_analytics.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1060,14 +1060,14 @@ def test_any_all_bool_only(self):
10601060
(np.any, {"A": pd.Series([0.0, 1.0], dtype="float")}, True),
10611061
(np.all, {"A": pd.Series([0, 1], dtype=int)}, False),
10621062
(np.any, {"A": pd.Series([0, 1], dtype=int)}, True),
1063-
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="M8[ns]")}, False,),
1064-
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="M8[ns]")}, True,),
1065-
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True,),
1066-
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True,),
1067-
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="m8[ns]")}, False,),
1068-
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="m8[ns]")}, True,),
1069-
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True,),
1070-
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True,),
1063+
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="M8[ns]")}, False),
1064+
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="M8[ns]")}, True),
1065+
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True),
1066+
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True),
1067+
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="m8[ns]")}, False),
1068+
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="m8[ns]")}, True),
1069+
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True),
1070+
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True),
10711071
(np.all, {"A": pd.Series([0, 1], dtype="category")}, False),
10721072
(np.any, {"A": pd.Series([0, 1], dtype="category")}, True),
10731073
(np.all, {"A": pd.Series([1, 2], dtype="category")}, True),

pandas/tests/io/formats/test_info.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ def test_info_memory_usage_qualified():
467467
assert "+" in buf.getvalue()
468468

469469
buf = StringIO()
470-
s = Series(1, index=MultiIndex.from_product([range(3), range(3)]),)
470+
s = Series(1, index=MultiIndex.from_product([range(3), range(3)]))
471471
s.info(buf=buf)
472472
assert "+" not in buf.getvalue()
473473

474474
buf = StringIO()
475-
s = Series(1, index=MultiIndex.from_product([range(3), ["foo", "bar"]]),)
475+
s = Series(1, index=MultiIndex.from_product([range(3), ["foo", "bar"]]))
476476
s.info(buf=buf)
477477
assert "+" in buf.getvalue()
478478

pandas/tests/io/test_gcs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
109109
compression["method"] = "infer"
110110
path_gcs += f".{compression_only}"
111111
df.to_csv(
112-
path_gcs, compression=compression, encoding=encoding,
112+
path_gcs,
113+
compression=compression,
114+
encoding=encoding,
113115
)
114116
assert gcs_buffer.getvalue() == buffer.getvalue()
115117
read_df = read_csv(path_gcs, index_col=0, compression="infer", encoding=encoding)

pandas/tests/io/test_parquet.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,9 @@ def test_s3_roundtrip(self, df_compat, s3_resource, pa, s3so):
572572
pytest.param(
573573
["A"],
574574
marks=pytest.mark.xfail(
575-
PY38, reason="Getting back empty DataFrame", raises=AssertionError,
575+
PY38,
576+
reason="Getting back empty DataFrame",
577+
raises=AssertionError,
576578
),
577579
),
578580
[],

pandas/tests/scalar/timestamp/test_constructors.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,20 @@ def test_constructor_keyword(self):
259259
Timestamp("20151112")
260260
)
261261

262-
assert repr(
263-
Timestamp(
264-
year=2015,
265-
month=11,
266-
day=12,
267-
hour=1,
268-
minute=2,
269-
second=3,
270-
microsecond=999999,
262+
assert (
263+
repr(
264+
Timestamp(
265+
year=2015,
266+
month=11,
267+
day=12,
268+
hour=1,
269+
minute=2,
270+
second=3,
271+
microsecond=999999,
272+
)
271273
)
272-
) == repr(Timestamp("2015-11-12 01:02:03.999999"))
274+
== repr(Timestamp("2015-11-12 01:02:03.999999"))
275+
)
273276

274277
def test_constructor_fromordinal(self):
275278
base = datetime(2000, 1, 1)

pandas/tests/series/test_operators.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ def test_unary_minus_nullable_int(
555555
tm.assert_series_equal(result, expected)
556556

557557
@pytest.mark.parametrize(
558-
"source", [[1, 2, 3], [1, 2, None], [-1, 0, 1]],
558+
"source",
559+
[[1, 2, 3], [1, 2, None], [-1, 0, 1]],
559560
)
560561
def test_unary_plus_nullable_int(self, any_signed_nullable_int_dtype, source):
561562
dtype = any_signed_nullable_int_dtype

scripts/tests/test_validate_docstrings.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77

88
class BadDocstrings:
9-
"""Everything here has a bad docstring
10-
"""
9+
"""Everything here has a bad docstring"""
1110

1211
def private_classes(self):
1312
"""

versioneer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
10731073
fmt = "tag '%s' doesn't start with prefix '%s'"
10741074
print(fmt % (full_tag, tag_prefix))
10751075
pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format(
1076-
full_tag, tag_prefix,
1076+
full_tag,
1077+
tag_prefix,
10771078
)
10781079
return pieces
10791080
pieces["closest-tag"] = full_tag[len(tag_prefix) :]

0 commit comments

Comments
 (0)