Skip to content

Commit 84b38aa

Browse files
committed
Fix E501: format long lines in series.py and test_subtraction_nanindex.py
1 parent 823d890 commit 84b38aa

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

pandas/core/series.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5904,9 +5904,12 @@ def _align_for_op(self, right, align_asobject=False, fill_value=np.nan):
59045904
if not (hasattr(left.index, "levels") or hasattr(right.index, "levels")):
59055905
if align_asobject:
59065906
if left.empty or right.empty:
5907-
if left.dtype not in (object, np.bool_) or right.dtype not in (object, np.bool_):
5907+
if left.dtype not in (object, np.bool_) or right.dtype not in (
5908+
object,
5909+
np.bool_,
5910+
):
59085911
return left.iloc[0:0], right.iloc[0:0]
5909-
return left.align(right, join='outer', fill_value=fill_value)
5912+
return left.align(right, join="outer", fill_value=fill_value)
59105913

59115914
if hasattr(left.index, "levels") and not hasattr(right.index, "levels"):
59125915
if left.empty or right.empty:
@@ -5918,8 +5921,8 @@ def _align_for_op(self, right, align_asobject=False, fill_value=np.nan):
59185921
right_aligned = right.reindex(first_level, fill_value=fill_value)
59195922
return left, right_aligned
59205923

5921-
return left.align(right, join='outer', fill_value=fill_value)
5922-
5924+
return left.align(right, join="outer", fill_value=fill_value)
5925+
59235926
def _binop(self, other: Series, func, level=None, fill_value=None) -> Series:
59245927
"""
59255928
Perform generic binary operation with optional fill value.
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
import pytest
2-
import pandas as pd
31
import numpy as np
2+
3+
import pandas as pd
44
import pandas.testing as tm
55

6+
67
def test_series_subtraction_with_nan_and_levels():
78
ix1 = pd.MultiIndex.from_arrays(
89
[
910
[np.nan, 81, 81, 82, 82],
1011
[np.nan] * 5,
11-
pd.to_datetime([np.nan, '2018-06-01', '2018-07-01', '2018-07-01', '2018-08-01'])
12+
pd.to_datetime(
13+
[np.nan, "2018-06-01", "2018-07-01", "2018-07-01", "2018-08-01"]
14+
),
1215
],
13-
names=['foo', 'bar', 'date']
16+
names=["foo", "bar", "date"],
1417
)
1518

16-
s1 = pd.Series(
17-
[np.nan, 25.058969, 22.519751, 20.847981, 21.625236],
18-
index=ix1
19-
)
19+
s1 = pd.Series([np.nan, 25.058969, 22.519751, 20.847981, 21.625236], index=ix1)
2020

21-
ix2 = pd.Index([81, 82, 83, 84, 85, 86, 87], name='foo')
21+
ix2 = pd.Index([81, 82, 83, 84, 85, 86, 87], name="foo")
2222
s2 = pd.Series(
23-
[28.2800, 25.2500, 22.2200, 16.7660, 14.0087, 14.9480, 29.2900],
24-
index=ix2
23+
[28.2800, 25.2500, 22.2200, 16.7660, 14.0087, 14.9480, 29.2900], index=ix2
2524
)
2625

2726
expected = pd.Series(
28-
[np.nan, -3.221031, -5.760249, -4.402019, -3.624764],
29-
index=ix1,
30-
dtype='float64'
27+
[np.nan, -3.221031, -5.760249, -4.402019, -3.624764], index=ix1, dtype="float64"
3128
)
3229

3330
result = s1 - s2
3431

35-
result = result.astype('float64')
32+
result = result.astype("float64")
3633

3734
tm.assert_series_equal(result, expected)
38-

0 commit comments

Comments
 (0)