Skip to content

Commit

Permalink
Rename get_last_val (#187)
Browse files Browse the repository at this point in the history
Yet another reminder to self to wait for Tom's comments before merging
:(
  • Loading branch information
spetravic authored Nov 9, 2023
1 parent b3692d6 commit 3d2939f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions emote/extra/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def __init__(self, initial: float, final: float, steps: int):
self.steps = steps

self._step_count = 0
self._last_val = initial
self._current_value = initial

def get_last_val(self) -> float:
return self._last_val
@property
def value(self):
return self._current_value

def step(self):
pass
Expand Down Expand Up @@ -79,7 +80,7 @@ def step(self):
fraction = math.floor(fraction * self.staircase_steps) / self.staircase_steps
fraction = min(fraction, 1.0)

self._last_val = self.initial + fraction * (self.final - self.initial)
self._current_value = self.initial + fraction * (self.final - self.initial)

self._step_count += 1

Expand Down Expand Up @@ -127,7 +128,7 @@ def step(self):
cycle = math.floor(1 + self._step_count / (2 * self.steps))
x = math.fabs(self._step_count / self.steps - 2 * cycle + 1)

self._last_val = self.initial + (self.final - self.initial) * max(
self._current_value = self.initial + (self.final - self.initial) * max(
0, (1 - x)
) * self.scale_fn(cycle)

Expand All @@ -149,13 +150,13 @@ def __init__(self, initial: float, final: float, steps: int):
def step(self):
if self._step_count > 0:
if (self._step_count - 1 - self.steps) % (2 * self.steps) == 0:
self._last_val += (
self._current_value += (
(self.initial - self.final) * (1 - math.cos(math.pi / self.steps)) / 2
)
else:
self._last_val = (1 + math.cos(math.pi * self._step_count / self.steps)) / (
self._current_value = (1 + math.cos(math.pi * self._step_count / self.steps)) / (
1 + math.cos(math.pi * (self._step_count - 1) / self.steps)
) * (self._last_val - self.final) + self.final
) * (self._current_value - self.final) + self.final

self._step_count += 1

Expand All @@ -176,7 +177,7 @@ def step(self):
if self._step_count >= self.steps:
self._step_count %= self.steps

self._last_val = (
self._current_value = (
self.final
+ (self.initial - self.final)
* (1 + math.cos(math.pi * self._step_count / self.steps))
Expand Down

0 comments on commit 3d2939f

Please sign in to comment.