@@ -456,8 +456,12 @@ def scalars(draw, dtypes, finite=False, **kwds):
456
456
dtypes should be one of the shared_* dtypes strategies.
457
457
"""
458
458
dtype = draw (dtypes )
459
+ mM = kwds .pop ('mM' , None )
459
460
if dh .is_int_dtype (dtype ):
460
- m , M = dh .dtype_ranges [dtype ]
461
+ if mM is None :
462
+ m , M = dh .dtype_ranges [dtype ]
463
+ else :
464
+ m , M = mM
461
465
return draw (integers (m , M ))
462
466
elif dtype == bool_dtype :
463
467
return draw (booleans ())
@@ -588,18 +592,20 @@ def two_mutual_arrays(
588
592
589
593
590
594
@composite
591
- def array_and_py_scalar (draw , dtypes ):
595
+ def array_and_py_scalar (draw , dtypes , mM = None , positive = False ):
592
596
"""Draw a pair: (array, scalar) or (scalar, array)."""
593
597
dtype = draw (sampled_from (dtypes ))
594
598
595
- scalar_var = draw (scalars (just (dtype ), finite = True ,
596
- ** { 'min_value' : 1 / ( 2 << 5 ), 'max_value' : 2 << 5 }
597
- ) )
599
+ scalar_var = draw (scalars (just (dtype ), finite = True , mM = mM ))
600
+ if positive :
601
+ assume ( scalar_var > 0 )
598
602
599
603
elements = {}
600
604
if dtype in dh .real_float_dtypes :
601
605
elements = {'allow_nan' : False , 'allow_infinity' : False ,
602
606
'min_value' : 1.0 / (2 << 5 ), 'max_value' : 2 << 5 }
607
+ if positive :
608
+ elements = {'min_value' : 0 }
603
609
array_var = draw (arrays (dtype , shape = shapes (min_dims = 1 ), elements = elements ))
604
610
605
611
if draw (booleans ()):
0 commit comments