@@ -146,31 +146,42 @@ def test_compare_datetime64_and_string():
146146
147147
148148def test_eq_objects ():
149- """ Test eq with Enum and List elements"""
149+ # GH#62191 Test eq with Enum and List elements
150150
151151 class Thing (Enum ):
152152 FIRST = auto ()
153153 SECOND = auto ()
154154
155155 left = pd .Series ([Thing .FIRST , Thing .SECOND ])
156- tm .assert_series_equal (left .eq (Thing .FIRST ), left == Thing .FIRST )
156+
157+ result_scalar = left .eq (Thing .FIRST )
158+ expected_scalar = left == Thing .FIRST
159+ tm .assert_series_equal (result_scalar , expected_scalar )
157160
158161 py_l = [Thing .FIRST , Thing .SECOND ]
159- tm .assert_series_equal (left .eq (py_l ), left == py_l )
162+ result_py_l = left .eq (py_l )
163+ expected_py_l = left == py_l
164+ tm .assert_series_equal (result_py_l , expected_py_l )
160165
161166 np_a = np .asarray (py_l )
162- tm .assert_series_equal (left .eq (np_a ), left == np_a )
167+ result_np_a = left .eq (np_a )
168+ expected_np_a = left == np_a
169+ tm .assert_series_equal (result_np_a , expected_np_a )
163170
164171 pd_s = pd .Series (py_l )
165- tm .assert_series_equal (left .eq (pd_s ), left == pd_s )
172+ result_pd_s = left .eq (pd_s )
173+ expected_pd_s = left == pd_s
174+ tm .assert_series_equal (result_pd_s , expected_pd_s )
166175
167176 left_non_scalar = pd .Series ([[1 , 2 ], [3 , 4 ]])
177+ result_non_scalar = left_non_scalar .eq ([1 , 2 ])
178+ expected_would_be = pd .Series ([True , False ])
168179 with pytest .raises (AssertionError ):
169- tm .assert_series_equal (left_non_scalar . eq ([ 1 , 2 ]), pd . Series ([ True , False ]) )
180+ tm .assert_series_equal (result_non_scalar , expected_would_be )
170181
171182
172183def test_eq_with_index ():
173- """ Test eq with non-trivial indices"""
184+ # GH#62191 Test eq with non-trivial indices
174185 left = pd .Series ([1 , 2 ], index = [1 , 0 ])
175186
176187 py_l = [1 , 2 ]
@@ -182,8 +193,4 @@ def test_eq_with_index():
182193 pd_s = pd .Series (py_l )
183194 tm .assert_series_equal (left .eq (pd_s ), pd .Series ([False , False ]))
184195
185- match = r"Can only compare identically-labeled Series objects"
186- with pytest .raises (ValueError , match = match ):
187- _ = left == pd_s
188-
189196 tm .assert_series_equal (left .eq (pd .Series ([2 , 1 ])), pd .Series ([True , True ]))
0 commit comments