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

Optimized wait generators. #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Optimized wait generators. #204

wants to merge 1 commit into from

Conversation

jcbertin
Copy link

Removed usage of the ** operator in expo() generator.
Fixed default min_value for decay() generator: saved a test in the limit condition.
Saved a couple of tests for limit condition in all generators.

Comment on lines 54 to +61
t = 0
while True:
a = initial_value
while a > min_value:
yield a
t += 1
a = initial_value * math.e ** (-t * decay_factor)
if min_value is None or a > min_value:
yield a
t += 1
else:
yield min_value
while True:
yield min_value
Copy link

@yxtay yxtay Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following what's done in expo to remove use of **.

Suggested change
t = 0
while True:
a = initial_value
while a > min_value:
yield a
t += 1
a = initial_value * math.e ** (-t * decay_factor)
if min_value is None or a > min_value:
yield a
t += 1
else:
yield min_value
while True:
yield min_value
a = initial_value
while a > min_value:
yield a
a /= math.exp(decay_factor)
while True:
yield min_value

Alternatively for line 57.

        a *= math.exp(-decay_factor)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants