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

Add math.inf to all_time_ratio calculation #7868

Merged
merged 1 commit into from
Jan 30, 2024
Merged

Conversation

drew2a
Copy link
Contributor

@drew2a drew2a commented Jan 30, 2024

This PR fixes #7865 by adding math.inf to the all_time_ratio formula.

image

@drew2a drew2a marked this pull request as ready for review January 30, 2024 07:38
@drew2a drew2a requested review from a team and kozlovsky and removed request for a team January 30, 2024 07:38
Copy link
Contributor

@kozlovsky kozlovsky left a comment

Choose a reason for hiding this comment

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

Interestingly, the JSON standard does not allow Infinity or NaN values, but Python extends the format by including them: https://docs.python.org/3/library/json.html#infinite-and-nan-number-values.

As Tribler GUI and Core are both in Python, it should be fine.

return 0

if not self.all_time_download:
return 0 if not self.all_time_upload else float("inf")
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: I slightly prefer math.inf to float("inf"), but both are possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Changed.

@drew2a drew2a changed the title Add float('inf') to all_time_ratio calculation Add math.inf to all_time_ratio calculation Jan 30, 2024
@drew2a drew2a merged commit b98285a into Tribler:main Jan 30, 2024
20 checks passed
@drew2a drew2a deleted the fix/7865 branch January 30, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

For seeders, the torrent ratio is shown as zero
2 participants