Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename get_last_val #187

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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