Skip to content

Commit 5362f81

Browse files
committed
Use black 19.10b0
1 parent 6498bc1 commit 5362f81

24 files changed

+65
-41
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/python/black
3-
rev: stable
3+
rev: 19.10b0
44
hooks:
55
- id: black
66
language_version: python3.7

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
- cython>=0.29.13
1616

1717
# code checks
18-
- black<=19.3b0
18+
- black>=19.10b0
1919
- cpplint
2020
- flake8
2121
- flake8-comprehensions # used by flake8, linting of unnecessary comprehensions

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ def compute(self, method):
11531153
n = min(n, narr)
11541154

11551155
kth_val = algos.kth_smallest(arr.copy(), n - 1)
1156-
ns, = np.nonzero(arr <= kth_val)
1156+
(ns,) = np.nonzero(arr <= kth_val)
11571157
inds = ns[arr[ns].argsort(kind="mergesort")]
11581158

11591159
if self.keep != "all":

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4793,7 +4793,7 @@ def drop_duplicates(self, subset=None, keep="first", inplace=False):
47934793
duplicated = self.duplicated(subset, keep=keep)
47944794

47954795
if inplace:
4796-
inds, = (-duplicated)._ndarray_values.nonzero()
4796+
(inds,) = (-duplicated)._ndarray_values.nonzero()
47974797
new_data = self._data.take(inds)
47984798
self._update_inplace(new_data)
47994799
else:

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3604,7 +3604,7 @@ class animal locomotion
36043604

36053605
if isinstance(loc, np.ndarray):
36063606
if loc.dtype == np.bool_:
3607-
inds, = loc.nonzero()
3607+
(inds,) = loc.nonzero()
36083608
return self.take(inds, axis=axis)
36093609
else:
36103610
return self.take(loc, axis=axis)

pandas/core/groupby/grouper.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ def __init__(
287287
if self.name is None:
288288
self.name = index.names[level]
289289

290-
self.grouper, self._codes, self._group_index = index._get_grouper_for_level( # noqa: E501
290+
(
291+
self.grouper,
292+
self._codes,
293+
self._group_index,
294+
) = index._get_grouper_for_level( # noqa: E501
291295
self.grouper, level
292296
)
293297

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ def _isnan(self):
18691869
@cache_readonly
18701870
def _nan_idxs(self):
18711871
if self._can_hold_na:
1872-
w, = self._isnan.nonzero()
1872+
(w,) = self._isnan.nonzero()
18731873
return w
18741874
else:
18751875
return np.array([], dtype=np.int64)

pandas/core/indexing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def _setitem_with_indexer(self, indexer, value):
319319
# if there is only one block/type, still have to take split path
320320
# unless the block is one-dimensional or it can hold the value
321321
if not take_split_path and self.obj._data.blocks:
322-
blk, = self.obj._data.blocks
322+
(blk,) = self.obj._data.blocks
323323
if 1 < blk.ndim: # in case of dict, keys are indices
324324
val = list(value.values()) if isinstance(value, dict) else value
325325
take_split_path = not blk._can_hold_element(val)
@@ -1111,7 +1111,7 @@ def _getitem_iterable(self, key, axis: int):
11111111
if com.is_bool_indexer(key):
11121112
# A boolean indexer
11131113
key = check_bool_indexer(labels, key)
1114-
inds, = key.nonzero()
1114+
(inds,) = key.nonzero()
11151115
return self.obj.take(inds, axis=axis)
11161116
else:
11171117
# A collection of keys
@@ -1255,7 +1255,7 @@ def _convert_to_indexer(self, obj, axis: int, raise_missing: bool = False):
12551255

12561256
if com.is_bool_indexer(obj):
12571257
obj = check_bool_indexer(labels, obj)
1258-
inds, = obj.nonzero()
1258+
(inds,) = obj.nonzero()
12591259
return inds
12601260
else:
12611261
# When setting, missing keys are not allowed, even with .loc:

pandas/core/internals/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ def _shape_compat(x):
18621862

18631863

18641864
def _interleaved_dtype(
1865-
blocks: List[Block]
1865+
blocks: List[Block],
18661866
) -> Optional[Union[np.dtype, ExtensionDtype]]:
18671867
"""Find the common dtype for `blocks`.
18681868

pandas/io/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _is_url(url) -> bool:
109109

110110

111111
def _expand_user(
112-
filepath_or_buffer: FilePathOrBuffer[AnyStr]
112+
filepath_or_buffer: FilePathOrBuffer[AnyStr],
113113
) -> FilePathOrBuffer[AnyStr]:
114114
"""Return the argument with an initial component of ~ or ~user
115115
replaced by that user's home directory.
@@ -139,7 +139,7 @@ def _validate_header_arg(header) -> None:
139139

140140

141141
def _stringify_path(
142-
filepath_or_buffer: FilePathOrBuffer[AnyStr]
142+
filepath_or_buffer: FilePathOrBuffer[AnyStr],
143143
) -> FilePathOrBuffer[AnyStr]:
144144
"""Attempt to convert a path-like object to a string.
145145

pandas/io/parsers.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,12 @@ def __init__(self, src, **kwds):
19181918
else:
19191919
if len(self._reader.header) > 1:
19201920
# we have a multi index in the columns
1921-
self.names, self.index_names, self.col_names, passed_names = self._extract_multi_indexer_columns( # noqa: E501
1921+
(
1922+
self.names,
1923+
self.index_names,
1924+
self.col_names,
1925+
passed_names,
1926+
) = self._extract_multi_indexer_columns( # noqa: E501
19221927
self._reader.header, self.index_names, self.col_names, passed_names
19231928
)
19241929
else:
@@ -2307,7 +2312,12 @@ def __init__(self, f, **kwds):
23072312
# The original set is stored in self.original_columns.
23082313
if len(self.columns) > 1:
23092314
# we are processing a multi index column
2310-
self.columns, self.index_names, self.col_names, _ = self._extract_multi_indexer_columns( # noqa: E501
2315+
(
2316+
self.columns,
2317+
self.index_names,
2318+
self.col_names,
2319+
_,
2320+
) = self._extract_multi_indexer_columns( # noqa: E501
23112321
self.columns, self.index_names, self.col_names
23122322
)
23132323
# Update list of original names to include all indices.

pandas/io/stata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def _cast_to_stata_types(data):
614614
data[col] = data[col].astype(np.int32)
615615
else:
616616
data[col] = data[col].astype(np.float64)
617-
if data[col].max() >= 2 ** 53 or data[col].min() <= -2 ** 53:
617+
if data[col].max() >= 2 ** 53 or data[col].min() <= -(2 ** 53):
618618
ws = precision_loss_doc % ("int64", "float64")
619619
elif dtype in (np.float32, np.float64):
620620
value = data[col].max()

pandas/tests/arrays/sparse/test_array.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,16 @@ def test_getslice_tuple(self):
658658
dense = np.array([np.nan, 0, 3, 4, 0, 5, np.nan, np.nan, 0])
659659

660660
sparse = SparseArray(dense)
661-
res = sparse[4:,] # noqa: E231
661+
res = sparse[
662+
4:,
663+
] # noqa: E231
662664
exp = SparseArray(dense[4:,]) # noqa: E231
663665
tm.assert_sp_array_equal(res, exp)
664666

665667
sparse = SparseArray(dense, fill_value=0)
666-
res = sparse[4:,] # noqa: E231
668+
res = sparse[
669+
4:,
670+
] # noqa: E231
667671
exp = SparseArray(dense[4:,], fill_value=0) # noqa: E231
668672
tm.assert_sp_array_equal(res, exp)
669673

@@ -823,11 +827,11 @@ def test_nonzero(self):
823827
# Tests regression #21172.
824828
sa = pd.SparseArray([float("nan"), float("nan"), 1, 0, 0, 2, 0, 0, 0, 3, 0, 0])
825829
expected = np.array([2, 5, 9], dtype=np.int32)
826-
result, = sa.nonzero()
830+
(result,) = sa.nonzero()
827831
tm.assert_numpy_array_equal(expected, result)
828832

829833
sa = pd.SparseArray([0, 0, 1, 0, 0, 2, 0, 0, 0, 3, 0, 0])
830-
result, = sa.nonzero()
834+
(result,) = sa.nonzero()
831835
tm.assert_numpy_array_equal(expected, result)
832836

833837

pandas/tests/dtypes/test_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def test_convert_numeric_int64_uint64(self, case, coerce):
505505
result = lib.maybe_convert_numeric(case, set(), coerce_numeric=coerce)
506506
tm.assert_almost_equal(result, expected)
507507

508-
@pytest.mark.parametrize("value", [-2 ** 63 - 1, 2 ** 64])
508+
@pytest.mark.parametrize("value", [-(2 ** 63) - 1, 2 ** 64])
509509
def test_convert_int_overflow(self, value):
510510
# see gh-18584
511511
arr = np.array([value], dtype=object)

pandas/tests/frame/test_constructors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ def test_constructor_overflow_int64(self):
245245
np.array([2 ** 64], dtype=object),
246246
np.array([2 ** 65]),
247247
[2 ** 64 + 1],
248-
np.array([-2 ** 63 - 4], dtype=object),
249-
np.array([-2 ** 64 - 1]),
250-
[-2 ** 65 - 2],
248+
np.array([-(2 ** 63) - 4], dtype=object),
249+
np.array([-(2 ** 64) - 1]),
250+
[-(2 ** 65) - 2],
251251
],
252252
)
253253
def test_constructor_int_overflow(self, values):

pandas/tests/indexes/period/test_construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def test_constructor_range_based_deprecated_different_freq(self):
434434
with tm.assert_produces_warning(FutureWarning) as m:
435435
PeriodIndex(start="2000", periods=2)
436436

437-
warning, = m
437+
(warning,) = m
438438
assert 'freq="A-DEC"' in str(warning.message)
439439

440440
def test_constructor(self):

pandas/tests/indexing/multiindex/test_getitem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_series_getitem_indexing_errors(
108108

109109

110110
def test_series_getitem_corner_generator(
111-
multiindex_year_month_day_dataframe_random_data
111+
multiindex_year_month_day_dataframe_random_data,
112112
):
113113
s = multiindex_year_month_day_dataframe_random_data["A"]
114114
result = s[(x > 0 for x in s)]

pandas/tests/indexing/multiindex/test_xs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_xs_level_series_ymd(multiindex_year_month_day_dataframe_random_data):
211211

212212

213213
def test_xs_level_series_slice_not_implemented(
214-
multiindex_year_month_day_dataframe_random_data
214+
multiindex_year_month_day_dataframe_random_data,
215215
):
216216
# this test is not explicitly testing .xs functionality
217217
# TODO: move to another module or refactor

pandas/tests/indexing/test_callable.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ def test_frame_loc_callable(self):
1717
res = df.loc[lambda x: x.A > 2]
1818
tm.assert_frame_equal(res, df.loc[df.A > 2])
1919

20-
res = df.loc[lambda x: x.A > 2,] # noqa: E231
20+
res = df.loc[
21+
lambda x: x.A > 2,
22+
] # noqa: E231
2123
tm.assert_frame_equal(res, df.loc[df.A > 2,]) # noqa: E231
2224

23-
res = df.loc[lambda x: x.A > 2,] # noqa: E231
25+
res = df.loc[
26+
lambda x: x.A > 2,
27+
] # noqa: E231
2428
tm.assert_frame_equal(res, df.loc[df.A > 2,]) # noqa: E231
2529

2630
res = df.loc[lambda x: x.B == "b", :]
@@ -90,7 +94,9 @@ def test_frame_loc_callable_labels(self):
9094
res = df.loc[lambda x: ["A", "C"]]
9195
tm.assert_frame_equal(res, df.loc[["A", "C"]])
9296

93-
res = df.loc[lambda x: ["A", "C"],] # noqa: E231
97+
res = df.loc[
98+
lambda x: ["A", "C"],
99+
] # noqa: E231
94100
tm.assert_frame_equal(res, df.loc[["A", "C"],]) # noqa: E231
95101

96102
res = df.loc[lambda x: ["A", "C"], :]

pandas/tests/io/parser/test_index_col.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def test_index_col_named(all_parsers, with_header):
2222
KORD5,19990127, 22:00:00, 21:56:00, -0.5900, 1.7100, 5.1000, 0.0000, 290.0000
2323
KORD6,19990127, 23:00:00, 22:56:00, -0.5900, 1.7100, 4.6000, 0.0000, 280.0000""" # noqa
2424
header = (
25-
"ID,date,NominalTime,ActualTime,TDew,TAir,Windspeed,Precip,WindDir\n"
26-
) # noqa
25+
"ID,date,NominalTime,ActualTime,TDew,TAir,Windspeed,Precip,WindDir\n" # noqa
26+
)
2727

2828
if with_header:
2929
data = header + no_header

pandas/tests/reductions/test_reductions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ class TestIndexReductions:
179179
[
180180
(0, 400, 3),
181181
(500, 0, -6),
182-
(-10 ** 6, 10 ** 6, 4),
183-
(10 ** 6, -10 ** 6, -4),
182+
(-(10 ** 6), 10 ** 6, 4),
183+
(10 ** 6, -(10 ** 6), -4),
184184
(0, 10, 20),
185185
],
186186
)

pandas/tests/test_algos.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ def test_uint64_factorize(self, writable):
215215
tm.assert_numpy_array_equal(uniques, exp_uniques)
216216

217217
def test_int64_factorize(self, writable):
218-
data = np.array([2 ** 63 - 1, -2 ** 63, 2 ** 63 - 1], dtype=np.int64)
218+
data = np.array([2 ** 63 - 1, -(2 ** 63), 2 ** 63 - 1], dtype=np.int64)
219219
data.setflags(write=writable)
220220
exp_labels = np.array([0, 1, 0], dtype=np.intp)
221-
exp_uniques = np.array([2 ** 63 - 1, -2 ** 63], dtype=np.int64)
221+
exp_uniques = np.array([2 ** 63 - 1, -(2 ** 63)], dtype=np.int64)
222222

223223
labels, uniques = algos.factorize(data)
224224
tm.assert_numpy_array_equal(labels, exp_labels)
@@ -257,7 +257,7 @@ def test_deprecate_order(self):
257257
"data",
258258
[
259259
np.array([0, 1, 0], dtype="u8"),
260-
np.array([-2 ** 63, 1, -2 ** 63], dtype="i8"),
260+
np.array([-(2 ** 63), 1, -(2 ** 63)], dtype="i8"),
261261
np.array(["__nan__", "foo", "__nan__"], dtype="object"),
262262
],
263263
)
@@ -274,8 +274,8 @@ def test_parametrized_factorize_na_value_default(self, data):
274274
[
275275
(np.array([0, 1, 0, 2], dtype="u8"), 0),
276276
(np.array([1, 0, 1, 2], dtype="u8"), 1),
277-
(np.array([-2 ** 63, 1, -2 ** 63, 0], dtype="i8"), -2 ** 63),
278-
(np.array([1, -2 ** 63, 1, 0], dtype="i8"), 1),
277+
(np.array([-(2 ** 63), 1, -(2 ** 63), 0], dtype="i8"), -(2 ** 63)),
278+
(np.array([1, -(2 ** 63), 1, 0], dtype="i8"), 1),
279279
(np.array(["a", "", "a", "b"], dtype=object), "a"),
280280
(np.array([(), ("a", 1), (), ("a", 2)], dtype=object), ()),
281281
(np.array([("a", 1), (), ("a", 1), ("a", 2)], dtype=object), ("a", 1)),

pandas/tests/test_nanops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def test_nanmean_overflow(self):
302302
# In the previous implementation mean can overflow for int dtypes, it
303303
# is now consistent with numpy
304304

305-
for a in [2 ** 55, -2 ** 55, 20150515061816532]:
305+
for a in [2 ** 55, -(2 ** 55), 20150515061816532]:
306306
s = Series(a, index=range(500), dtype=np.int64)
307307
result = s.mean()
308308
np_result = s.values.mean()

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ python-dateutil>=2.6.1
33
pytz
44
asv
55
cython>=0.29.13
6-
black<=19.3b0
6+
black>=19.10b0
77
cpplint
88
flake8
99
flake8-comprehensions

0 commit comments

Comments
 (0)