@@ -597,6 +597,41 @@ def test_stringops(values):
597597 np .testing .assert_array_equal (expr_lazy [:], res_numexpr )
598598
599599
600+ def test_stringops2 ():
601+ # test all supported string ops for bytes and strings
602+ for t in ("bytes" , "string" ):
603+ if t == "bytes" :
604+ a1 = np .array ([b"abc" , b"def" , b"aterr" , b"oot" , b"zu" , b"ab c" ])
605+ a2 = a2_blosc = b"a"
606+ else :
607+ a1 = np .array (["abc" , "def" , "aterr" , "oot" , "zu" , "ab c" ])
608+ a2 = a2_blosc = "a"
609+ a1_blosc = blosc2 .asarray (a1 )
610+ for func , npfunc in zip (
611+ (blosc2 .startswith , blosc2 .endswith , blosc2 .contains ),
612+ (np .char .startswith , np .char .endswith , lambda * args : np .char .find (* args ) != - 1 ),
613+ strict = True ,
614+ ):
615+ expr_lazy = func (a1_blosc , a2_blosc )
616+ res_numexpr = npfunc (a1 , a2 )
617+ assert expr_lazy .shape == res_numexpr .shape
618+ assert expr_lazy .dtype == blosc2 .bool_
619+ np .testing .assert_array_equal (expr_lazy [:], res_numexpr )
620+
621+ np .testing .assert_array_equal ((a1_blosc < a2_blosc )[:], a1 < a2 )
622+ np .testing .assert_array_equal ((a1_blosc <= a2_blosc )[:], a1 <= a2 )
623+ np .testing .assert_array_equal ((a1_blosc == a2_blosc )[:], a1 == a2 )
624+ np .testing .assert_array_equal ((a1_blosc != a2_blosc )[:], a1 != a2 )
625+ np .testing .assert_array_equal ((a1_blosc >= a2_blosc )[:], a1 >= a2 )
626+ np .testing .assert_array_equal ((a1_blosc > a2_blosc )[:], a1 > a2 )
627+
628+ for func , npfunc in zip ((blosc2 .lower , blosc2 .upper ), (np .char .lower , np .char .upper ), strict = True ):
629+ expr_lazy = func (a1_blosc )
630+ res_numexpr = npfunc (a1 )
631+ assert expr_lazy .shape == res_numexpr .shape
632+ np .testing .assert_array_equal (expr_lazy [:], res_numexpr )
633+
634+
600635def test_negate (dtype_fixture , shape_fixture ):
601636 nelems = np .prod (shape_fixture )
602637 na1 = np .linspace (- 1 , 1 , nelems , dtype = dtype_fixture ).reshape (shape_fixture )
0 commit comments