Number helpers#
- ivy_tests.test_ivy.helpers.hypothesis_helpers.number_helpers.floats(*, min_value=None, max_value=None, abs_smallest_val=None, allow_nan=False, allow_inf=False, allow_subnormal=False, exclude_min=True, exclude_max=True, large_abs_safety_factor=1.1, small_abs_safety_factor=1.1, safety_factor_scale='linear')[source]#
Draws an arbitrarily sized list of floats with a safety factor applied to avoid values being generated at the edge of a dtype limit.
- Parameters:
draw – special function that draws data randomly (but is reproducible) from a given data-set (ex. list).
min_value – minimum value of floats generated.
max_value – maximum value of floats generated.
abs_smallest_val – the absolute smallest representable value of the data type.
allow_nan – if True, allow Nans in the list.
allow_inf – if True, allow inf in the list.
allow_subnormal – if True, allow subnormals in the list.
exclude_min – if True, exclude the minimum limit.
exclude_max – if True, exclude the maximum limit.
large_abs_safety_factor –
A safety factor of 1 means that all values are included without limitation,
when a “linear” safety factor scaler is used, a safety factor of 2 means that only 50% of the range is included, a safety factor of 3 means that only 33% of the range is included etc.
when a “log” safety factor scaler is used, a data type with maximum value of 2^32 and a safety factor of 2 transforms the maximum to 2^16.
small_abs_safety_factor –
A safety factor of 1 means that all values are included without limitation,
when a “linear” safety factor scaler is used, a data type with minimum representable number of 0.0001 and a safety factor of 2 transforms the minimum to 0.0002, a safety factor of 3 transforms the minimum to 0.0003 etc.
when a “log” safety factor scaler is used, a data type with minimum representable number of 0.5 * 2^-16 and a safety factor of 2 transforms the minimum to 0.5 * 2^-8, a safety factor of 3 transforms the minimum to 0.5 * 2^-4
safety_factor_scale – The operation to use for the safety factor scaling. Can be “linear” or “log”. Default value = “linear”.
- Return type:
SearchStrategy
- Returns:
ret – A strategy that draws floats.
- ivy_tests.test_ivy.helpers.hypothesis_helpers.number_helpers.ints(*, min_value=None, max_value=None, safety_factor=1.1, safety_factor_scale=None)[source]#
Draws an integer with a safety factor if specified.
- Parameters:
draw – special function that draws data randomly (but is reproducible) from a given data-set (ex. list).
min_value – minimum value of integers generated.
max_value – maximum value of integers generated.
safety_factor –
A safety factor of 1 means that all values are included without limitation,
when a “linear” safety factor scaler is used, a safety factor of 2 means that only 50% of the range is included, a safety factor of 3 means that only 33% of the range is included etc.
when a “log” safety factor scaler is used, a data type with maximum value of 2^32 and a safety factor of 2 transforms the maximum to 2^16.
safety_factor_scale – The operation to use for the safety factor scaling. Can be “linear” or “log”. Default value = “linear”.
- Return type:
SearchStrategy
- Returns:
ret – A strategy that draws integers.
- ivy_tests.test_ivy.helpers.hypothesis_helpers.number_helpers.number(*, min_value=None, max_value=None, large_abs_safety_factor=1.1, small_abs_safety_factor=1.1, safety_factor_scale='linear')[source]#
Draws integers or floats with a safety factor applied to values.
- Parameters:
draw – special function that draws data randomly (but is reproducible) from a given data-set (ex. list).
min_value – minimum value of integers generated.
max_value – maximum value of integers generated.
large_abs_safety_factor –
A safety factor of 1 means that all values are included without limitation,
when a “linear” safety factor scaler is used, a safety factor of 2 means that only 50% of the range is included, a safety factor of 3 means that only 33% of the range is included etc.
when a “log” safety factor scaler is used, a data type with maximum value of 2^32 and a safety factor of 2 transforms the maximum to 2^16.
small_abs_safety_factor –
A safety factor of 1 means that all values are included without limitation, this has no effect on integer data types.
when a “linear” safety factor scaler is used, a data type with minimum representable number of 0.0001 and a safety factor of 2 transforms the minimum to 0.0002, a safety factor of 3 transforms the minimum to 0.0003 etc.
when a “log” safety factor scaler is used, a data type with minimum representable number of 0.5 * 2^-16 and a safety factor of 2 transforms the minimum to 0.5 * 2^-8, a safety factor of 3 transforms the minimum to 0.5 * 2^-4
safety_factor_scale – The operation to use for the safety factor scaling. Can be “linear” or “log”. Default value = “linear”.
- Return type:
SearchStrategy
- Returns:
ret – A strategy that draws integers or floats.