next_in_grid¶
- emlib.mathlib.next_in_grid(x, step, offset)[source]¶
The next value in the grid defined by step/offset which is >= x
- Parameters:
x (
TypeVar(T,float,Fraction)) – a value to fit to the next division of a gridstep (
TypeVar(T,float,Fraction)) – the step of the gridoffset (
TypeVar(T,float,Fraction)) – the offset of the grid
- Return type:
TypeVar(T,float,Fraction)- 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)