Skip to content

Commit 6ab5843

Browse files
committed
changes made by black pandas
1 parent 3c63b6f commit 6ab5843

26 files changed

+42
-83
lines changed

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ def to_feather(self, path):
19841984
@Substitution(klass="DataFrame")
19851985
@Appender(_shared_docs["to_markdown"])
19861986
def to_markdown(
1987-
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs,
1987+
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
19881988
) -> Optional[str]:
19891989
kwargs.setdefault("headers", "keys")
19901990
kwargs.setdefault("tablefmt", "pipe")

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _outer_indexer(self, left, right):
265265
# Constructors
266266

267267
def __new__(
268-
cls, data=None, dtype=None, copy=False, name=None, tupleize_cols=True, **kwargs,
268+
cls, data=None, dtype=None, copy=False, name=None, tupleize_cols=True, **kwargs
269269
) -> "Index":
270270

271271
from .range import RangeIndex

pandas/core/indexes/category.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ def _engine_type(self):
164164
# Constructors
165165

166166
def __new__(
167-
cls,
168-
data=None,
169-
categories=None,
170-
ordered=None,
171-
dtype=None,
172-
copy=False,
173-
name=None,
167+
cls, data=None, categories=None, ordered=None, dtype=None, copy=False, name=None
174168
):
175169

176170
dtype = CategoricalDtype._from_values_or_dtype(data, categories, ordered, dtype)

pandas/core/indexes/range.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class RangeIndex(Int64Index):
8181
# Constructors
8282

8383
def __new__(
84-
cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None,
84+
cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None
8585
):
8686

8787
cls._validate_dtype(dtype)

pandas/core/ops/__init__.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@
8282
}
8383

8484

85-
COMPARISON_BINOPS: Set[str] = {
86-
"eq",
87-
"ne",
88-
"lt",
89-
"gt",
90-
"le",
91-
"ge",
92-
}
85+
COMPARISON_BINOPS: Set[str] = {"eq", "ne", "lt", "gt", "le", "ge"}
9386

9487
# -----------------------------------------------------------------------------
9588
# Ops Wrapping Utilities

pandas/core/ops/dispatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def should_series_dispatch(left, right, op):
9696

9797

9898
def dispatch_to_extension_op(
99-
op, left: Union[ABCExtensionArray, np.ndarray], right: Any,
99+
op, left: Union[ABCExtensionArray, np.ndarray], right: Any
100100
):
101101
"""
102102
Assume that left or right is a Series backed by an ExtensionArray,

pandas/core/series.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ def to_string(
14331433
@Substitution(klass="Series")
14341434
@Appender(_shared_docs["to_markdown"])
14351435
def to_markdown(
1436-
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs,
1436+
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
14371437
) -> Optional[str]:
14381438
return self.to_frame().to_markdown(buf, mode, **kwargs)
14391439

@@ -4395,9 +4395,7 @@ def to_period(self, freq=None, copy=True):
43954395
hist = pandas.plotting.hist_series
43964396

43974397

4398-
Series._setup_axes(
4399-
["index"], docs={"index": "The index (axis labels) of the Series."},
4400-
)
4398+
Series._setup_axes(["index"], docs={"index": "The index (axis labels) of the Series."})
44014399
Series._add_numeric_operations()
44024400
Series._add_series_or_dataframe_operations()
44034401

pandas/core/window/indexers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BaseIndexer:
3535
"""Base class for window bounds calculations"""
3636

3737
def __init__(
38-
self, index_array: Optional[np.ndarray] = None, window_size: int = 0, **kwargs,
38+
self, index_array: Optional[np.ndarray] = None, window_size: int = 0, **kwargs
3939
):
4040
"""
4141
Parameters
@@ -100,7 +100,7 @@ def get_window_bounds(
100100
) -> Tuple[np.ndarray, np.ndarray]:
101101

102102
return calculate_variable_window_bounds(
103-
num_values, self.window_size, min_periods, center, closed, self.index_array,
103+
num_values, self.window_size, min_periods, center, closed, self.index_array
104104
)
105105

106106

pandas/core/window/numba_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def impl(window, *_args):
6363

6464
@numba.jit(nopython=nopython, nogil=nogil, parallel=parallel)
6565
def roll_apply(
66-
values: np.ndarray, begin: np.ndarray, end: np.ndarray, minimum_periods: int,
66+
values: np.ndarray, begin: np.ndarray, end: np.ndarray, minimum_periods: int
6767
) -> np.ndarray:
6868
result = np.empty(len(begin))
6969
for i in loop_range(len(result)):

pandas/io/formats/css.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def expand(self, prop, value: str):
2020
try:
2121
mapping = self.SIDE_SHORTHANDS[len(tokens)]
2222
except KeyError:
23-
warnings.warn(
24-
f'Could not expand "{prop}: {value}"', CSSWarning,
25-
)
23+
warnings.warn(f'Could not expand "{prop}: {value}"', CSSWarning)
2624
return
2725
for key, idx in zip(self.SIDES, mapping):
2826
yield prop_fmt.format(key), tokens[idx]
@@ -117,10 +115,7 @@ def __call__(self, declarations_str, inherited=None):
117115
props[prop] = self.size_to_pt(
118116
props[prop], em_pt=font_size, conversions=self.BORDER_WIDTH_RATIOS
119117
)
120-
for prop in [
121-
f"margin-{side}",
122-
f"padding-{side}",
123-
]:
118+
for prop in [f"margin-{side}", f"padding-{side}"]:
124119
if prop in props:
125120
# TODO: support %
126121
props[prop] = self.size_to_pt(

pandas/io/formats/excel.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ def build_border(self, props):
134134
return {
135135
side: {
136136
"style": self._border_style(
137-
props.get(f"border-{side}-style"),
138-
props.get(f"border-{side}-width"),
137+
props.get(f"border-{side}-style"), props.get(f"border-{side}-width")
139138
),
140139
"color": self.color_to_excel(props.get(f"border-{side}-color")),
141140
}

pandas/io/formats/style.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,7 @@ def format_attr(pair):
291291

292292
# ... except maybe the last for columns.names
293293
name = self.data.columns.names[r]
294-
cs = [
295-
BLANK_CLASS if name is None else INDEX_NAME_CLASS,
296-
f"level{r}",
297-
]
294+
cs = [BLANK_CLASS if name is None else INDEX_NAME_CLASS, f"level{r}"]
298295
name = BLANK_VALUE if name is None else name
299296
row_es.append(
300297
{
@@ -308,11 +305,7 @@ def format_attr(pair):
308305

309306
if clabels:
310307
for c, value in enumerate(clabels[r]):
311-
cs = [
312-
COL_HEADING_CLASS,
313-
f"level{r}",
314-
f"col{c}",
315-
]
308+
cs = [COL_HEADING_CLASS, f"level{r}", f"col{c}"]
316309
cs.extend(
317310
cell_context.get("col_headings", {}).get(r, {}).get(c, [])
318311
)
@@ -356,11 +349,7 @@ def format_attr(pair):
356349
for r, idx in enumerate(self.data.index):
357350
row_es = []
358351
for c, value in enumerate(rlabels[r]):
359-
rid = [
360-
ROW_HEADING_CLASS,
361-
f"level{c}",
362-
f"row{r}",
363-
]
352+
rid = [ROW_HEADING_CLASS, f"level{c}", f"row{r}"]
364353
es = {
365354
"type": "th",
366355
"is_visible": (_is_visible(r, c, idx_lengths) and not hidden_index),

pandas/io/orc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def read_orc(
15-
path: FilePathOrBuffer, columns: Optional[List[str]] = None, **kwargs,
15+
path: FilePathOrBuffer, columns: Optional[List[str]] = None, **kwargs
1616
) -> "DataFrame":
1717
"""
1818
Load an ORC object from the file path, returning a DataFrame.

pandas/io/pytables.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ def read_index_node(
28302830
# If the index was an empty array write_array_empty() will
28312831
# have written a sentinel. Here we relace it with the original.
28322832
if "shape" in node._v_attrs and np.prod(node._v_attrs.shape) == 0:
2833-
data = np.empty(node._v_attrs.shape, dtype=node._v_attrs.value_type,)
2833+
data = np.empty(node._v_attrs.shape, dtype=node._v_attrs.value_type)
28342834
kind = _ensure_decoded(node._v_attrs.kind)
28352835
name = None
28362836

@@ -3574,10 +3574,7 @@ def _read_axes(
35743574
for a in self.axes:
35753575
a.set_info(self.info)
35763576
res = a.convert(
3577-
values,
3578-
nan_rep=self.nan_rep,
3579-
encoding=self.encoding,
3580-
errors=self.errors,
3577+
values, nan_rep=self.nan_rep, encoding=self.encoding, errors=self.errors
35813578
)
35823579
results.append(res)
35833580

@@ -4003,7 +4000,7 @@ def create_description(
40034000
return d
40044001

40054002
def read_coordinates(
4006-
self, where=None, start: Optional[int] = None, stop: Optional[int] = None,
4003+
self, where=None, start: Optional[int] = None, stop: Optional[int] = None
40074004
):
40084005
"""select coordinates (row numbers) from a table; return the
40094006
coordinates object
@@ -4264,7 +4261,7 @@ def write_data_chunk(
42644261
self.table.flush()
42654262

42664263
def delete(
4267-
self, where=None, start: Optional[int] = None, stop: Optional[int] = None,
4264+
self, where=None, start: Optional[int] = None, stop: Optional[int] = None
42684265
):
42694266

42704267
# delete all rows (and return the nrows)
@@ -4695,7 +4692,7 @@ def _convert_index(name: str, index: Index, encoding: str, errors: str) -> Index
46954692
if inferred_type == "date":
46964693
converted = np.asarray([v.toordinal() for v in values], dtype=np.int32)
46974694
return IndexCol(
4698-
name, converted, "date", _tables().Time32Col(), index_name=index_name,
4695+
name, converted, "date", _tables().Time32Col(), index_name=index_name
46994696
)
47004697
elif inferred_type == "string":
47014698

@@ -4711,13 +4708,13 @@ def _convert_index(name: str, index: Index, encoding: str, errors: str) -> Index
47114708

47124709
elif inferred_type in ["integer", "floating"]:
47134710
return IndexCol(
4714-
name, values=converted, kind=kind, typ=atom, index_name=index_name,
4711+
name, values=converted, kind=kind, typ=atom, index_name=index_name
47154712
)
47164713
else:
47174714
assert isinstance(converted, np.ndarray) and converted.dtype == object
47184715
assert kind == "object", kind
47194716
atom = _tables().ObjectAtom()
4720-
return IndexCol(name, converted, kind, atom, index_name=index_name,)
4717+
return IndexCol(name, converted, kind, atom, index_name=index_name)
47214718

47224719

47234720
def _unconvert_index(

pandas/tests/arithmetic/test_numeric.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class TestNumericArraylikeArithmeticWithDatetimeLike:
9595
# TODO: also check name retentention
9696
@pytest.mark.parametrize("box_cls", [np.array, pd.Index, pd.Series])
9797
@pytest.mark.parametrize(
98-
"left", lefts, ids=lambda x: type(x).__name__ + str(x.dtype),
98+
"left", lefts, ids=lambda x: type(x).__name__ + str(x.dtype)
9999
)
100100
def test_mul_td64arr(self, left, box_cls):
101101
# GH#22390
@@ -115,7 +115,7 @@ def test_mul_td64arr(self, left, box_cls):
115115
# TODO: also check name retentention
116116
@pytest.mark.parametrize("box_cls", [np.array, pd.Index, pd.Series])
117117
@pytest.mark.parametrize(
118-
"left", lefts, ids=lambda x: type(x).__name__ + str(x.dtype),
118+
"left", lefts, ids=lambda x: type(x).__name__ + str(x.dtype)
119119
)
120120
def test_div_td64arr(self, left, box_cls):
121121
# GH#22390

pandas/tests/arrays/test_boolean.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,7 @@ def test_kleene_xor_scalar(self, other, expected):
565565
a, pd.array([True, False, None], dtype="boolean")
566566
)
567567

568-
@pytest.mark.parametrize(
569-
"other", [True, False, pd.NA, [True, False, None] * 3],
570-
)
568+
@pytest.mark.parametrize("other", [True, False, pd.NA, [True, False, None] * 3])
571569
def test_no_masked_assumptions(self, other, all_logical_operators):
572570
# The logical operations should not assume that masked values are False!
573571
a = pd.arrays.BooleanArray(

pandas/tests/arrays/test_timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_incorrect_dtype_raises(self):
4646
TimedeltaArray(np.array([1, 2, 3], dtype="i8"), dtype="category")
4747

4848
with pytest.raises(
49-
ValueError, match=r"dtype int64 cannot be converted to timedelta64\[ns\]",
49+
ValueError, match=r"dtype int64 cannot be converted to timedelta64\[ns\]"
5050
):
5151
TimedeltaArray(np.array([1, 2, 3], dtype="i8"), dtype=np.dtype("int64"))
5252

pandas/tests/base/test_conversion.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,7 @@ def test_array_multiindex_raises():
313313
pd.core.arrays.period_array(["2000", "2001"], freq="D"),
314314
np.array([pd.Period("2000", freq="D"), pd.Period("2001", freq="D")]),
315315
),
316-
(
317-
pd.core.arrays.integer_array([0, np.nan]),
318-
np.array([0, pd.NA], dtype=object),
319-
),
316+
(pd.core.arrays.integer_array([0, np.nan]), np.array([0, pd.NA], dtype=object)),
320317
(
321318
pd.core.arrays.IntervalArray.from_breaks([0, 1, 2]),
322319
np.array([pd.Interval(0, 1), pd.Interval(1, 2)], dtype=object),

pandas/tests/indexing/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def check_values(self, f, func, values=False):
170170
tm.assert_almost_equal(result, expected)
171171

172172
def check_result(
173-
self, method1, key1, method2, key2, typs=None, axes=None, fails=None,
173+
self, method1, key1, method2, key2, typs=None, axes=None, fails=None
174174
):
175175
def _eq(axis, obj, key1, key2):
176176
""" compare equal for these 2 keys """

pandas/tests/indexing/test_loc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_loc_getitem_label_out_of_range(self):
116116
self.check_result("loc", "f", "ix", "f", typs=["floats"], fails=KeyError)
117117
self.check_result("loc", "f", "loc", "f", typs=["floats"], fails=KeyError)
118118
self.check_result(
119-
"loc", 20, "loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError,
119+
"loc", 20, "loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError
120120
)
121121
self.check_result("loc", 20, "loc", 20, typs=["labels"], fails=TypeError)
122122
self.check_result("loc", 20, "loc", 20, typs=["ts"], axes=0, fails=TypeError)
@@ -129,7 +129,7 @@ def test_loc_getitem_label_list(self):
129129

130130
def test_loc_getitem_label_list_with_missing(self):
131131
self.check_result(
132-
"loc", [0, 1, 2], "loc", [0, 1, 2], typs=["empty"], fails=KeyError,
132+
"loc", [0, 1, 2], "loc", [0, 1, 2], typs=["empty"], fails=KeyError
133133
)
134134
self.check_result(
135135
"loc",

pandas/tests/io/formats/test_format.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2385,8 +2385,7 @@ def test_east_asian_unicode_series(self):
23852385

23862386
# object dtype, longer than unicode repr
23872387
s = Series(
2388-
[1, 22, 3333, 44444],
2389-
index=[1, "AB", pd.Timestamp("2011-01-01"), "あああ"],
2388+
[1, 22, 3333, 44444], index=[1, "AB", pd.Timestamp("2011-01-01"), "あああ"]
23902389
)
23912390
expected = (
23922391
"1 1\n"

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):

pandas/tests/series/methods/test_argsort.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TestSeriesArgsort:
99
def _check_accum_op(self, name, ser, check_dtype=True):
1010
func = getattr(np, name)
1111
tm.assert_numpy_array_equal(
12-
func(ser).values, func(np.array(ser)), check_dtype=check_dtype,
12+
func(ser).values, func(np.array(ser)), check_dtype=check_dtype
1313
)
1414

1515
# with missing values

pandas/tests/series/test_cumulative.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def _check_accum_op(name, series, check_dtype=True):
1818
func = getattr(np, name)
1919
tm.assert_numpy_array_equal(
20-
func(series).values, func(np.array(series)), check_dtype=check_dtype,
20+
func(series).values, func(np.array(series)), check_dtype=check_dtype
2121
)
2222

2323
# with missing values

pandas/util/_test_decorators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable:
181181
is_platform_windows(), reason="not used on win32"
182182
)
183183
skip_if_has_locale = pytest.mark.skipif(
184-
_skip_if_has_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}",
184+
_skip_if_has_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}"
185185
)
186186
skip_if_not_us_locale = pytest.mark.skipif(
187-
_skip_if_not_us_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}",
187+
_skip_if_not_us_locale(), reason=f"Specific locale is set {locale.getlocale()[0]}"
188188
)
189189
skip_if_no_scipy = pytest.mark.skipif(
190190
_skip_if_no_scipy(), reason="Missing SciPy requirement"

0 commit comments

Comments
 (0)