next_in_grid¶
- emlib.mathlib.next_in_grid(x, step, offset=0)[source]¶
The next value in the grid defined by step/offset which is >= x
- Parameters:
x (
Union
[Rational
,float
]) – a value to fit to the next division of a gridstep (
Union
[Rational
,float
]) – the step of the gridoffset (
Union
[Rational
,float
]) – the offset of the grid
- Return type:
float
- Returns
the next value within the grid higher or equal to x
Example
>>> next_in_grid(4.3, 0.5, 0) 4.5 >>> from fractions import Fraction >>> next_in_grid(1.31, Fraction(1, 3)) Fraction(4, 3)