@@ -172,6 +172,41 @@ def test_xarray_ufuncs_deprecation():
172
172
with pytest .warns (PendingDeprecationWarning , match = 'xarray.ufuncs' ):
173
173
xu .cos (xr .DataArray ([0 , 1 ]))
174
174
175
+ with pytest .warns (None ) as record :
176
+ xu .angle (xr .DataArray ([0 , 1 ]))
177
+ record = [el .message for el in record
178
+ if el .category == PendingDeprecationWarning ]
179
+ assert len (record ) == 0
180
+
181
+
182
+ @requires_np113
183
+ @pytest .mark .filterwarnings ('ignore::RuntimeWarning' )
184
+ @pytest .mark .parametrize (
185
+ 'name' ,
186
+ [name for name in dir (xu )
187
+ if (not name .startswith ('_' ) and hasattr (np , name )
188
+ and name not in ['print_function' , 'absolute_import' , 'division' ])]
189
+ )
190
+ def test_numpy_ufuncs (name , request ):
191
+ x = xr .DataArray ([1 , 1 ])
192
+
193
+ np_func = getattr (np , name )
194
+ if hasattr (np_func , 'nin' ) and np_func .nin == 2 :
195
+ args = (x , x )
196
+ else :
197
+ args = (x ,)
198
+
199
+ y = np_func (* args )
200
+
201
+ if name in ['angle' , 'iscomplex' ]:
202
+ # these functions need to be handled with __array_function__ protocol
203
+ assert isinstance (y , np .ndarray )
204
+ elif name in ['frexp' ]:
205
+ # np.frexp returns a tuple
206
+ assert not isinstance (y , xr .DataArray )
207
+ else :
208
+ assert isinstance (y , xr .DataArray )
209
+
175
210
176
211
def test_xarray_ufuncs_pickle ():
177
212
a = 1.0
0 commit comments