Pass **kwargs through npst.from_dtype() to the inferred strategy
#2552
Labels
enhancement
it's not broken, but we want it to be better
Consider the following pattern:
If
width=None, when the generated dtype is float32 we will trigger the warning for inexact representation of element values (which is useful in general, if annoying here). Alternatively, ifwidth=32then we have massively reduced the precision of the element values that we can generate when the dtype is float64. There are of course workarounds with e.g. flatmap in current use, but they're pretty ugly and awkward for new users.I therefore propose that:
npst.from_dtype()should take**kwargs, and pass them through to whichever strategy function it chooses. In practice this would usually just bemin_valueandmax_valuefor integers or floats, but using**kwargsgives a cleaner implementation and allows use with timestamps, complex numbers, string length, and so on.arrays()strategy would then takeelements: Union[SearchStrategy, Mapping[str, Any]] = None. The mapping case would then be used as kwargs for a call tofrom_dtype().CC co-designer @rsokl.
The text was updated successfully, but these errors were encountered: