3
3
zeros , zeros_like , isnan )
4
4
from .array_helpers import (is_integer_dtype , dtype_ranges ,
5
5
assert_exactly_equal , isintegral , is_float_dtype )
6
- from .hypothesis_helpers import (numeric_dtypes , dtypes , MAX_ARRAY_SIZE ,
6
+ from .hypothesis_helpers import (numeric_dtypes , dtypes , MAX_ARRAY_SIZE , promotable_dtypes ,
7
7
shapes , sizes , sqrt_sizes , shared_dtypes ,
8
8
scalars , xps )
9
9
@@ -84,7 +84,7 @@ def test_empty(shape, dtype):
84
84
dtype = shared_dtypes ,
85
85
shape = xps .array_shapes (),
86
86
),
87
- dtype = one_of (none (), shared_dtypes ),
87
+ dtype = one_of (none (), shared_dtypes . flatmap ( promotable_dtypes ) ),
88
88
)
89
89
def test_empty_like (a , dtype ):
90
90
kwargs = {} if dtype is None else {'dtype' : dtype }
@@ -96,7 +96,7 @@ def test_empty_like(a, dtype):
96
96
# assert is_float_dtype(a_like.dtype), "empty_like() should produce an array with the default floating point dtype"
97
97
pass
98
98
else :
99
- assert a_like .dtype == a . dtype , "empty_like() produced an array with an incorrect dtype"
99
+ assert a_like .dtype == dtype , "empty_like() produced an array with an incorrect dtype"
100
100
101
101
assert a_like .shape == a .shape , "empty_like() produced an array with an incorrect shape"
102
102
@@ -155,8 +155,8 @@ def test_full(shape, fill_value, dtype):
155
155
dtype = shared_dtypes ,
156
156
shape = xps .array_shapes (),
157
157
),
158
- fill_value = shared_dtypes .flatmap (xps .from_dtype ),
159
- dtype = one_of (none (), shared_dtypes ),
158
+ fill_value = shared_dtypes .flatmap (promotable_dtypes ). flatmap ( xps .from_dtype ),
159
+ dtype = one_of (none (), shared_dtypes . flatmap ( promotable_dtypes ) ),
160
160
)
161
161
def test_full_like (a , fill_value , dtype ):
162
162
kwargs = {} if dtype is None else {'dtype' : dtype }
@@ -167,13 +167,13 @@ def test_full_like(a, fill_value, dtype):
167
167
# TODO: Should it actually match a.dtype?
168
168
pass
169
169
else :
170
- assert a_like .dtype == a . dtype
170
+ assert a_like .dtype == dtype
171
171
172
172
assert a_like .shape == a .shape , "full_like() produced an array with incorrect shape"
173
173
if is_float_dtype (a_like .dtype ) and isnan (asarray (fill_value )):
174
174
assert all (isnan (a_like )), "full_like() array did not equal the fill value"
175
175
else :
176
- assert all (equal (a_like , asarray (fill_value , dtype = a .dtype ))), "full_like() array did not equal the fill value"
176
+ assert all (equal (a_like , asarray (fill_value , dtype = a_like .dtype ))), "full_like() array did not equal the fill value"
177
177
178
178
179
179
@given (scalars (shared_dtypes , finite = True ),
@@ -247,7 +247,7 @@ def test_ones(shape, dtype):
247
247
dtype = shared_dtypes ,
248
248
shape = xps .array_shapes (),
249
249
),
250
- dtype = one_of (none (), shared_dtypes ),
250
+ dtype = one_of (none (), shared_dtypes . flatmap ( promotable_dtypes ) ),
251
251
)
252
252
def test_ones_like (a , dtype ):
253
253
kwargs = {} if dtype is None else {'dtype' : dtype }
@@ -260,11 +260,11 @@ def test_ones_like(a, dtype):
260
260
261
261
a_like = ones_like (a , ** kwargs )
262
262
263
- if kwargs is None :
263
+ if dtype is None :
264
264
# TODO: Should it actually match a.dtype?
265
265
pass
266
266
else :
267
- assert a_like .dtype == a . dtype , "ones_like() produced an array with an incorrect dtype"
267
+ assert a_like .dtype == dtype , "ones_like() produced an array with an incorrect dtype"
268
268
269
269
assert a_like .shape == a .shape , "ones_like() produced an array with an incorrect shape"
270
270
assert all (equal (a_like , full ((), ONE , dtype = a_like .dtype ))), "ones_like() array did not equal 1"
@@ -298,7 +298,7 @@ def test_zeros(shape, dtype):
298
298
dtype = shared_dtypes ,
299
299
shape = xps .array_shapes (),
300
300
),
301
- dtype = one_of (none (), shared_dtypes ),
301
+ dtype = one_of (none (), shared_dtypes . flatmap ( promotable_dtypes ) ),
302
302
)
303
303
def test_zeros_like (a , dtype ):
304
304
kwargs = {} if dtype is None else {'dtype' : dtype }
@@ -311,11 +311,11 @@ def test_zeros_like(a, dtype):
311
311
312
312
a_like = zeros_like (a , ** kwargs )
313
313
314
- if kwargs is None :
314
+ if dtype is None :
315
315
# TODO: Should it actually match a.dtype?
316
316
pass
317
317
else :
318
- assert a_like .dtype == a . dtype , "zeros_like() produced an array with an incorrect dtype"
318
+ assert a_like .dtype == dtype , "zeros_like() produced an array with an incorrect dtype"
319
319
320
320
assert a_like .shape == a .shape , "zeros_like() produced an array with an incorrect shape"
321
321
assert all (equal (a_like , full ((), ZERO , dtype = a_like .dtype ))), "zeros_like() array did not equal 0"
0 commit comments