Skip to content

Commit 4a32460

Browse files
committed
upgrade version of 'black'
1 parent dbf17ff commit 4a32460

File tree

23 files changed

+104
-67
lines changed

23 files changed

+104
-67
lines changed

asv_bench/benchmarks/arithmetic.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 6 deletions
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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
198198
# Constructors
199199

200200
def __init__(
201-
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False,
201+
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False
202202
):
203203

204204
if (
@@ -208,9 +208,7 @@ def __init__(
208208
and copy is False
209209
):
210210
# GH#33357 called with just the SingleBlockManager
211-
NDFrame.__init__(
212-
self, data,
213-
)
211+
NDFrame.__init__(self, data)
214212
self.name = name
215213
return
216214

@@ -330,7 +328,8 @@ def __init__(
330328
data = SingleBlockManager.from_array(data, index)
331329

332330
generic.NDFrame.__init__(
333-
self, data,
331+
self,
332+
data,
334333
)
335334
self.name = name
336335
self._set_axis(0, index, fastpath=True)

pandas/core/sorting.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,6 @@ def _format(x):
13821382

13831383

13841384
class FloatArrayFormatter(GenericArrayFormatter):
1385-
"""
1386-
1387-
"""
1388-
13891385
def __init__(self, *args, **kwargs):
13901386
super().__init__(*args, **kwargs)
13911387

pandas/io/formats/info.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,29 @@ def _verbose_repr(
340340
if show_counts:
341341
count = counts[i]
342342

343-
lines.append(
344-
line_no
345-
+ _put_str(col, space)
346-
+ _put_str(count_temp.format(count=count), space_count)
347-
+ _put_str(dtype, space_dtype)
348-
)
343+
def _verbose_repr(
344+
self, lines: List[str], ids: "Index", dtypes: "Series", show_counts: bool
345+
) -> None:
346+
lines.append(f"Series name: {self.data.name}")
347+
348+
id_space = 2
349+
350+
counts = cast("Series", self.data._constructor(self.data.count()))
351+
count_configs = _get_count_configs(counts, id_space, show_counts)
352+
353+
space_dtype, header, len_dtype = _get_header_and_spaces(
354+
dtypes, count_configs.space_count, count_configs.count_header
355+
)
356+
357+
lines.append(header)
358+
lines.append(
359+
_put_str("-" * count_configs.len_count, count_configs.space_count)
360+
+ _put_str("-" * len_dtype, space_dtype)
361+
)
362+
363+
_display_counts_and_dtypes(
364+
lines, ids, dtypes, show_counts, count_configs, space_dtype
365+
)
349366

350367
def _non_verbose_repr(self, lines: List[str], ids: "Index") -> None:
351368
lines.append(ids._summary(name="Columns"))

pandas/io/formats/latex.py

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,26 @@ def test_info_memory_usage_qualified():
371371
df.info(buf=buf)
372372
assert "+" in buf.getvalue()
373373

374+
buf = StringIO()
375+
s = Series(1, index=[1, 2, 3])
376+
s.info(buf=buf)
377+
assert "+" not in buf.getvalue()
378+
379+
buf = StringIO()
380+
s = Series(1, index=list("ABC"))
381+
s.info(buf=buf)
382+
assert "+" in buf.getvalue()
383+
384+
buf = StringIO()
385+
s = Series(1, index=MultiIndex.from_product([range(3), range(3)]))
386+
s.info(buf=buf)
387+
assert "+" not in buf.getvalue()
388+
389+
buf = StringIO()
390+
s = Series(1, index=MultiIndex.from_product([range(3), ["foo", "bar"]]))
391+
s.info(buf=buf)
392+
assert "+" in buf.getvalue()
393+
374394

375395
def test_info_memory_usage_bug_on_multiindex():
376396
# GH 14308

pandas/tests/io/test_gcs.py

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 13 additions & 10 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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)