3131UNARY_FUNC_PAIRS .append ((np .round , blosc2 .round ))
3232UNARY_FUNC_PAIRS .append ((np .count_nonzero , blosc2 .count_nonzero ))
3333
34- DTYPES = [np .bool_ , np .int32 , np .int64 , np .float32 , np .float64 , np .complex128 ]
34+ DTYPES = [blosc2 .bool_ , blosc2 .int32 , blosc2 .int64 , blosc2 .float32 , blosc2 .float64 , blosc2 .complex128 ]
3535SHAPES_CHUNKS = [((10 ,), (3 ,)), ((20 , 20 ), (4 , 7 )), ((10 , 13 , 13 ), (3 , 5 , 2 ))]
3636
3737
@@ -43,20 +43,20 @@ def test_unary_funcs(np_func, blosc_func, dtype, shape, chunkshape): # noqa : C
4343 a_blosc = blosc2 .linspace (
4444 0.01 , stop = 0.99 , num = np .prod (shape ), chunks = chunkshape , shape = shape , dtype = dtype
4545 )
46- if not np . issubdtype (dtype , np . integer ):
46+ if not blosc2 . isdtype (dtype , "integral" ):
4747 a_blosc [tuple (i // 2 for i in shape )] = blosc2 .nan
48- if dtype == np .complex128 :
48+ if dtype == blosc2 .complex128 :
4949 a_blosc = (a_blosc * (1 + 1j )).compute ()
5050 a_blosc [tuple (i // 2 for i in shape )] = blosc2 .nan + blosc2 .nan * 1j
51- if dtype == np . bool and np_func .__name__ == "arctanh" :
51+ if dtype == blosc2 . bool_ and np_func .__name__ == "arctanh" :
5252 a_blosc = blosc2 .zeros (chunks = chunkshape , shape = shape , dtype = dtype )
5353 else :
5454 a_blosc = blosc2 .linspace (
5555 1 , stop = np .prod (shape ), num = np .prod (shape ), chunks = chunkshape , shape = shape , dtype = dtype
5656 )
57- if not np . issubdtype (dtype , np . integer ):
57+ if not blosc2 . isdtype (dtype , "integral" ):
5858 a_blosc [tuple (i // 2 for i in shape )] = blosc2 .nan
59- if dtype == np .complex128 :
59+ if dtype == blosc2 .complex128 :
6060 a_blosc = (
6161 a_blosc
6262 + blosc2 .linspace (
@@ -87,12 +87,16 @@ def test_unary_funcs(np_func, blosc_func, dtype, shape, chunkshape): # noqa : C
8787 # some functions don't support certain dtypes and that's fine
8888 assert True
8989 except ValueError as e :
90- if np_func .__name__ == "logical_not" and dtype in (np .float32 , np .float64 , np .complex128 ):
90+ if np_func .__name__ == "logical_not" and dtype in (
91+ blosc2 .float32 ,
92+ blosc2 .float64 ,
93+ blosc2 .complex128 ,
94+ ):
9195 assert True
9296 else :
9397 raise e
9498 except AssertionError as e :
95- if np_func .__name__ in ("tan" , "tanh" ) and dtype == np .complex128 :
99+ if np_func .__name__ in ("tan" , "tanh" ) and dtype == blosc2 .complex128 :
96100 warnings .showwarning (
97101 "tan and tanh do not give correct NaN location" ,
98102 UserWarning ,
@@ -123,9 +127,9 @@ def test_binary_funcs(np_func, blosc_func, dtype, shape, chunkshape): # noqa :
123127 shape = shape ,
124128 dtype = dtype ,
125129 )
126- if not np . issubdtype (dtype , np . integer ):
130+ if not blosc2 . isdtype (dtype , "integral" ):
127131 a_blosc1 [tuple (i // 2 for i in shape )] = blosc2 .nan
128- if dtype == np .complex128 :
132+ if dtype == blosc2 .complex128 :
129133 a_blosc1 = (
130134 a_blosc1
131135 + blosc2 .linspace (
@@ -151,23 +155,26 @@ def test_binary_funcs(np_func, blosc_func, dtype, shape, chunkshape): # noqa :
151155 # some functions don't support certain dtypes and that's fine
152156 assert True
153157 except ValueError as e : # shouldn't be allowed for non-booleans
154- if np_func .__name__ in ("logical_and" , "logical_or" , "logical_xor" , "minimum" , "maximum" ):
158+ if np_func .__name__ in ("logical_and" , "logical_or" , "logical_xor" ):
159+ assert True
160+ if (
161+ np_func .__name__ in ("less" , "less_equal" , "greater" , "greater_equal" , "minimum" , "maximum" )
162+ and dtype == blosc2 .complex128
163+ ): # not supported for complex dtypes
155164 assert True
156165 else :
157166 raise e
158- except NotImplementedError as e : # shouldn't be allowed for non-booleans
167+ except NotImplementedError as e :
159168 if np_func .__name__ in ("left_shift" , "right_shift" , "floor_divide" , "power" , "remainder" ):
160169 assert True
161170 else :
162171 raise e
163172 except AssertionError as e :
164- if np_func .__name__ == "power" and np . issubdtype (
165- dtype , np . integer
173+ if np_func .__name__ == "power" and blosc2 . isdtype (
174+ dtype , "integral"
166175 ): # overflow causes disagreement, no problem
167176 assert True
168- elif np_func .__name__ in ("maximum" , "minimum" ) and np .issubdtype (
169- dtype , np .floating
170- ): # overflow causes disagreement, no problem
177+ elif np_func .__name__ in ("maximum" , "minimum" ) and blosc2 .isdtype (dtype , "real floating" ):
171178 warnings .showwarning (
172179 "minimum and maximum for numexpr do not match NaN behaviour for numpy" ,
173180 UserWarning ,
0 commit comments