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

Fix #1090 #1092

Merged
merged 3 commits into from
May 17, 2019
Merged

Fix #1090 #1092

merged 3 commits into from
May 17, 2019

Conversation

JustinDrake
Copy link
Contributor

@JustinDrake JustinDrake commented May 17, 2019

Avoid signed integers

Avoid signed integer
Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

👍👍

@@ -647,7 +647,7 @@ def get_previous_epoch(state: BeaconState) -> Epoch:
Return the current epoch if it's genesis epoch.
"""
current_epoch = get_current_epoch(state)
return (current_epoch - 1) if current_epoch > GENESIS_EPOCH else current_epoch
return GENESIS_EPOCH if current_epoch == GENESIS_EPOCH else current_epoch - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny tiny nitpick: the previous version looks fine to me, and slightly more efficient since we expect in most cases, current_epoch is greater than GENESIS_EPOCH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to make it clear that current_epoch - 1 is not even "considered" unless current_epoch != GENESIS. Not too fussed either way :)

Copy link
Contributor

Choose a reason for hiding this comment

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

So in python, the left side is never run if the conditional is False, but I think this makes it slightly clearer to be careful with the subtraction. I'm oky with as is

@djrtwo djrtwo merged commit 7e9b00f into dev May 17, 2019
@djrtwo djrtwo deleted the JustinDrake-patch-10 branch May 17, 2019 14:28
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.

3 participants