7
7
from pandas import Categorical , DataFrame , Series , date_range
8
8
from pandas .tests .arrays .categorical .common import TestCategorical
9
9
import pandas .util .testing as tm
10
+ import warnings
10
11
11
12
12
13
class TestCategoricalOpsWithFactor (TestCategorical ):
@@ -193,8 +194,14 @@ def test_comparison_of_ordered_categorical_with_nan_to_scalar(
193
194
# values should be evaluated as False
194
195
195
196
cat = Categorical ([1 , 2 , 3 , None ], categories = [1 , 2 , 3 ], ordered = True )
196
-
197
- assert getattr (cat , compare_operators_no_eq_ne )(2 )[- 1 ] == False
197
+ scalar = 2
198
+
199
+ with warnings .catch_warnings ():
200
+ warnings .simplefilter ("ignore" , RuntimeWarning )
201
+ actual = getattr (cat , compare_operators_no_eq_ne )(scalar )
202
+ expected = getattr (np .array (cat ), compare_operators_no_eq_ne )(scalar )
203
+ tm .assert_numpy_array_equal (actual , expected )
204
+
198
205
199
206
def test_comparison_of_ordered_categorical_with_nan_to_listlike (
200
207
self , compare_operators_no_eq_ne ):
@@ -204,7 +211,12 @@ def test_comparison_of_ordered_categorical_with_nan_to_listlike(
204
211
205
212
cat = Categorical ([1 , 2 , 3 , None ], categories = [1 , 2 , 3 ], ordered = True )
206
213
other = Categorical ([2 , 2 , 2 , 2 ], categories = [1 , 2 , 3 ], ordered = True )
207
- assert getattr (cat , compare_operators_no_eq_ne )(other )[- 1 ] == False
214
+
215
+ with warnings .catch_warnings ():
216
+ warnings .simplefilter ("ignore" , RuntimeWarning )
217
+ actual = getattr (cat , compare_operators_no_eq_ne )(other )
218
+ expected = getattr (np .array (cat ), compare_operators_no_eq_ne )(2 )
219
+ tm .assert_numpy_array_equal (actual , expected )
208
220
209
221
@pytest .mark .parametrize ('data,reverse,base' , [
210
222
(list ("abc" ), list ("cba" ), list ("bbb" )),
0 commit comments