Skip to content

Commit f3c1000

Browse files
committed
fixed failing tests
1 parent cfc40bb commit f3c1000

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

pandas/core/ops/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ def to_series(right):
313313
left, right = left.align(right, join="outer", level=level, copy=False)
314314
else:
315315
raise ValueError(
316-
"Can only compare identically-labeled (both index and columns)\
317-
DataFrame objects"
316+
"Can only compare identically-labeled "
317+
"(both index and columns) "
318+
"DataFrame objects"
318319
)
319320
elif isinstance(right, ABCSeries):
320321
# axis=1 is default for DataFrame-with-Series op

pandas/tests/frame/methods/test_compare.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,20 @@ def test_compare_multi_index(align_axis):
170170

171171
def test_compare_unaligned_objects():
172172
# test DataFrames with different indices
173-
msg = "Can only compare identically-labeled (both index and columns) DataFrame\
174-
objects"
173+
msg = (
174+
r"Can only compare identically-labeled \(both index and columns\) DataFrame "
175+
"objects"
176+
)
175177
with pytest.raises(ValueError, match=msg):
176178
df1 = pd.DataFrame([1, 2, 3], index=["a", "b", "c"])
177179
df2 = pd.DataFrame([1, 2, 3], index=["a", "b", "d"])
178180
df1.compare(df2)
179181

180182
# test DataFrames with different shapes
181-
msg = "Can only compare identically-labeled (both index and columns) DataFrame\
182-
objects"
183+
msg = (
184+
r"Can only compare identically-labeled \(both index and columns\) DataFrame "
185+
"objects"
186+
)
183187
with pytest.raises(ValueError, match=msg):
184188
df1 = pd.DataFrame(np.ones((3, 3)))
185189
df2 = pd.DataFrame(np.zeros((2, 1)))

pandas/tests/frame/test_arithmetic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,10 @@ def test_comparisons(self, simple_frame, float_frame, func):
15361536
result3 = func(float_frame, 0)
15371537
tm.assert_numpy_array_equal(result3.values, func(float_frame.values, 0))
15381538

1539-
msg = "Can only compare identically-labeled (both index and columns)\
1540-
DataFrame objects"
1539+
msg = (
1540+
r"Can only compare identically-labeled \(both index and columns\) "
1541+
"DataFrame objects"
1542+
)
15411543
with pytest.raises(ValueError, match=msg):
15421544
func(simple_frame, simple_frame[:2])
15431545

pandas/tests/frame/test_nonunique_indexes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ def test_dup_columns_comparisons(self):
203203
df2 = DataFrame([[0, 1], [2, 4], [2, np.nan], [4, 5]], columns=["A", "A"])
204204

205205
# not-comparing like-labelled
206-
msg = "Can only compare identically-labeled (both index and columns) \
207-
DataFrame objects"
206+
msg = (
207+
r"Can only compare identically-labeled \(both index and columns\) "
208+
"DataFrame objects"
209+
)
208210
with pytest.raises(ValueError, match=msg):
209211
df1 == df2
210212

pandas/tests/series/test_arithmetic.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,20 @@ def test_comp_ops_df_compat(self, left, right, frame_or_series):
626626
# GH 1134
627627
# GH 50083 to clarify that index and columns must be identically labeled
628628
if frame_or_series is not Series:
629-
msg = f"Can only compare identically-labeled (both index and columns)\
630-
{frame_or_series.__name__} objects"
629+
631630
left = left.to_frame()
632631
right = right.to_frame()
632+
633+
msg = (
634+
"Can only compare identically-labeled "
635+
r"\(both index and columns\) "
636+
f"{frame_or_series.__name__} objects"
637+
)
633638
else:
634-
msg = f"Can only compare identically-labeled {frame_or_series.__name__}\
635-
objects"
639+
msg = (
640+
f"Can only compare identically-labeled {frame_or_series.__name__} "
641+
f"objects"
642+
)
636643
with pytest.raises(ValueError, match=msg):
637644
left == right
638645
with pytest.raises(ValueError, match=msg):

0 commit comments

Comments
 (0)