Without maximum
, floats are extremely constrained:
>>> create_random_float(Random(), minimum=100, maximum=None)
100.18084162477052
>>> create_random_float(Random(), minimum=100, maximum=None)
100.54924103325709
>>> create_random_float(Random(), minimum=100, maximum=None)
101.5380217963041
>>> create_random_float(Random(), minimum=100, maximum=None)
100.48749377309393
>>> create_random_float(Random(), minimum=100, maximum=None)
100.62887519044165
With maximum
, they are differentiated much more:
>>> create_random_float(Random(), minimum=100, maximum=1000)
922.9521500077755
>>> create_random_float(Random(), minimum=100, maximum=1000)
594.5901441349624
>>> create_random_float(Random(), minimum=100, maximum=1000)
668.6168721529523
>>> create_random_float(Random(), minimum=100, maximum=1000)
760.5950727117361
>>> create_random_float(Random(), minimum=100, maximum=1000)
269.2787865511392
I discovered this while debugging a factory of mine. It's a ModelFactory
(Pydantic), with a PositiveInt
field (built-in Pydantic type), and I found that Polyfactory barely differentiated those ints. I traced that to the create_random_float
function, and values passed to it.
I temporarily worked around this by using a custom Pydantic type with annotated_types.Le
, but believe this is not sane default behaviour.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too