from typing import Sequence from .charts_scale_linear_scale import interpolate, normalise, pair, round6 def invert_linear(domain: Sequence[float], range: Sequence[float], value: float) -> float: """The domain value at a position in the range: linear_scale read backwards. Never clamped; a position past the end of the axis is a value past the end of the data. """ d0, d1 = pair(domain, "domain") r0, r1 = pair(range, "range") return round6(interpolate(d0, d1, normalise(r0, r1, value, "range")))