@@ -1807,7 +1807,7 @@ def test_eq_ne_structured_extra(self):
18071807 el_by_el = [m1 [name ] != m2 [name ] for name in dt .names ]
18081808 assert_equal (array (el_by_el , dtype = bool ).any (), ne_expected )
18091809
1810- @pytest .mark .parametrize ('dt' , ['S' , 'U' ])
1810+ @pytest .mark .parametrize ('dt' , ['S' , 'U' , 'T' ])
18111811 @pytest .mark .parametrize ('fill' , [None , 'A' ])
18121812 def test_eq_for_strings (self , dt , fill ):
18131813 # Test the equality of structured arrays
@@ -1839,7 +1839,7 @@ def test_eq_for_strings(self, dt, fill):
18391839 assert_equal (test .mask , [True , False ])
18401840 assert_ (test .fill_value == True )
18411841
1842- @pytest .mark .parametrize ('dt' , ['S' , 'U' ])
1842+ @pytest .mark .parametrize ('dt' , ['S' , 'U' , 'T' ])
18431843 @pytest .mark .parametrize ('fill' , [None , 'A' ])
18441844 def test_ne_for_strings (self , dt , fill ):
18451845 # Test the equality of structured arrays
@@ -1989,17 +1989,26 @@ def test_comparisons_for_numeric(self, op, dt1, dt2, fill):
19891989 assert_equal (test .mask , [True , False ])
19901990 assert_ (test .fill_value == True )
19911991
1992+ @pytest .mark .parametrize ('dt' , ['S' , 'U' , 'T' ])
19921993 @pytest .mark .parametrize ('op' ,
19931994 [operator .le , operator .lt , operator .ge , operator .gt ])
19941995 @pytest .mark .parametrize ('fill' , [None , "N/A" ])
1995- def test_comparisons_strings (self , op , fill ):
1996+ def test_comparisons_strings (self , dt , op , fill ):
19961997 # See gh-21770, mask propagation is broken for strings (and some other
19971998 # cases) so we explicitly test strings here.
19981999 # In principle only == and != may need special handling...
1999- ma1 = masked_array (["a" , "b" , "cde" ], mask = [0 , 1 , 0 ], fill_value = fill )
2000- ma2 = masked_array (["cde" , "b" , "a" ], mask = [0 , 1 , 0 ], fill_value = fill )
2000+ ma1 = masked_array (["a" , "b" , "cde" ], mask = [0 , 1 , 0 ], fill_value = fill , dtype = dt )
2001+ ma2 = masked_array (["cde" , "b" , "a" ], mask = [0 , 1 , 0 ], fill_value = fill , dtype = dt )
20012002 assert_equal (op (ma1 , ma2 )._data , op (ma1 ._data , ma2 ._data ))
20022003
2004+ if isinstance (fill , str ):
2005+ fill = np .array (fill , dtype = dt )
2006+
2007+ ma1 = masked_array (["a" , "b" , "cde" ], mask = [0 , 1 , 0 ], fill_value = fill , dtype = dt )
2008+ ma2 = masked_array (["cde" , "b" , "a" ], mask = [0 , 1 , 0 ], fill_value = fill , dtype = dt )
2009+ assert_equal (op (ma1 , ma2 )._data , op (ma1 ._data , ma2 ._data ))
2010+
2011+
20032012 @pytest .mark .filterwarnings ("ignore:.*Comparison to `None`.*:FutureWarning" )
20042013 def test_eq_with_None (self ):
20052014 # Really, comparisons with None should not be done, but check them
0 commit comments