def step(self, value: Number, direction: str) -> StepperOutput: value = self.min_max.clip(value) max_ = self.min_max.max min_ = self.min_max.min step = (max_ - min_) / self.steps new_value = value + Stepper.apply_sign(step, direction) new_value = round(new_value, 3) if self.min_max.is_between(new_value): return StepperOutput(new_value, next_direction=direction) else: new_value = self.min_max.clip(new_value) return StepperOutput(new_value, next_direction=None)
def step(self, value: Number, direction: str) -> StepperOutput: value = self.min_max.clip(value) sign = Stepper.sign(direction) max_ = self.min_max.max min_ = self.min_max.min step = (max_ - min_) / self.steps new_value = value + sign * step if self.min_max.is_between(new_value): return StepperOutput(round(new_value, 3), next_direction=direction) else: new_value = 2 * self.min_max.clip(new_value) - new_value return StepperOutput( round(new_value, 3), next_direction=Stepper.invert_direction(direction))
def step(self, value: Number, direction: str) -> StepperOutput: value = self.min_max.clip(value) sign = self.sign(direction) # We add +1 to make the max be included max_ = int(self.min_max.max) + 1 min_ = int(self.min_max.min) step = (max_ - min_) // self.steps new_value = (int(value) + step * sign) % (max_ - min_) + min_ return StepperOutput(new_value, next_direction=direction)
def step(self, value: Number, direction: str) -> StepperOutput: value = self.min_max.clip(value) # We add +1 to include `max` max_ = self.min_max.max min_ = self.min_max.min step = (max_ - min_) / self.steps new_value = (((value + Stepper.apply_sign(step, direction)) - min_) % (max_ - min_)) + min_ new_value = round(new_value, 3) return StepperOutput(new_value, next_direction=direction)