@@ -81,18 +81,17 @@ def test_empty(shape, dtype):
81
81
82
82
@given (
83
83
a = xps .arrays (
84
- dtype = shared ( xps . scalar_dtypes (), key = 'dtypes' ) ,
84
+ dtype = shared_dtypes ,
85
85
shape = xps .array_shapes (),
86
86
),
87
- kwargs = one_of (
88
- just ({}),
89
- shared (xps .scalar_dtypes (), key = 'dtypes' ).map (lambda d : {'dtype' : d }),
90
- ),
87
+ dtype = one_of (none (), shared_dtypes ),
91
88
)
92
- def test_empty_like (a , kwargs ):
89
+ def test_empty_like (a , dtype ):
90
+ kwargs = {} if dtype is None else {'dtype' : dtype }
91
+
93
92
a_like = empty_like (a , ** kwargs )
94
93
95
- if kwargs is None :
94
+ if dtype is None :
96
95
# TODO: Should it actually match a.dtype?
97
96
# assert is_float_dtype(a_like.dtype), "empty_like() should produce an array with the default floating point dtype"
98
97
pass
@@ -153,26 +152,24 @@ def test_full(shape, fill_value, dtype):
153
152
154
153
@given (
155
154
a = xps .arrays (
156
- dtype = shared ( xps . scalar_dtypes (), key = 'dtypes' ) ,
155
+ dtype = shared_dtypes ,
157
156
shape = xps .array_shapes (),
158
157
),
159
- fill_value = shared (xps .scalar_dtypes (), key = 'dtypes' ).flatmap (xps .from_dtype ),
160
- kwargs = one_of (
161
- just ({}),
162
- shared (xps .scalar_dtypes (), key = 'dtypes' ).map (lambda d : {'dtype' : d }),
163
- ),
158
+ fill_value = shared_dtypes .flatmap (xps .from_dtype ),
159
+ dtype = one_of (none (), shared_dtypes ),
164
160
)
165
- def test_full_like (a , fill_value , kwargs ):
161
+ def test_full_like (a , fill_value , dtype ):
162
+ kwargs = {} if dtype is None else {'dtype' : dtype }
163
+
166
164
a_like = full_like (a , fill_value , ** kwargs )
167
165
168
- if kwargs is None :
166
+ if dtype is None :
169
167
# TODO: Should it actually match a.dtype?
170
168
pass
171
169
else :
172
170
assert a_like .dtype == a .dtype
173
171
174
172
assert a_like .shape == a .shape , "full_like() produced an array with incorrect shape"
175
-
176
173
if is_float_dtype (a_like .dtype ) and isnan (asarray (fill_value )):
177
174
assert all (isnan (a_like )), "full_like() array did not equal the fill value"
178
175
else :
@@ -247,15 +244,13 @@ def test_ones(shape, dtype):
247
244
248
245
@given (
249
246
a = xps .arrays (
250
- dtype = shared ( xps . scalar_dtypes (), key = 'dtypes' ) ,
247
+ dtype = shared_dtypes ,
251
248
shape = xps .array_shapes (),
252
249
),
253
- kwargs = one_of (
254
- just ({}),
255
- shared (xps .scalar_dtypes (), key = 'dtypes' ).map (lambda d : {'dtype' : d }),
256
- ),
250
+ dtype = one_of (none (), shared_dtypes ),
257
251
)
258
- def test_ones_like (a , kwargs ):
252
+ def test_ones_like (a , dtype ):
253
+ kwargs = {} if dtype is None else {'dtype' : dtype }
259
254
if kwargs is None or is_float_dtype (a .dtype ):
260
255
ONE = 1.0
261
256
elif is_integer_dtype (a .dtype ):
@@ -300,16 +295,14 @@ def test_zeros(shape, dtype):
300
295
301
296
@given (
302
297
a = xps .arrays (
303
- dtype = shared ( xps . scalar_dtypes (), key = 'dtypes' ) ,
298
+ dtype = shared_dtypes ,
304
299
shape = xps .array_shapes (),
305
300
),
306
- kwargs = one_of (
307
- just ({}),
308
- shared (xps .scalar_dtypes (), key = 'dtypes' ).map (lambda d : {'dtype' : d }),
309
- ),
301
+ dtype = one_of (none (), shared_dtypes ),
310
302
)
311
- def test_zeros_like (a , kwargs ):
312
- if kwargs is None or is_float_dtype (a .dtype ):
303
+ def test_zeros_like (a , dtype ):
304
+ kwargs = {} if dtype is None else {'dtype' : dtype }
305
+ if dtype is None or is_float_dtype (a .dtype ):
313
306
ZERO = 0.0
314
307
elif is_integer_dtype (a .dtype ):
315
308
ZERO = 0
0 commit comments