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

Return result percentage as fraction #24

Merged
merged 13 commits into from
Mar 20, 2024

Conversation

MasloMaslane
Copy link
Member

@MasloMaslane MasloMaslane commented Feb 20, 2024

Now sioworkers will return a tuple which represents a fraction of the points that the checker assigned. There are 3 formats:

  • the old one: [0-9]+
  • float: [0-9]+.[0-9]+
  • fraction [0-9]+ [0-9]+

This will allow more precise point assignment. Related sio2project/oioioi#332

output_is_percent = re.match(r"^[0-9]+$", output_str)
output_is_fraction = re.match(r"^[0-9]+ [0-9]+$", output_str)
if output_is_float:
return float_to_fraction(output_str)
Copy link
Contributor

Choose a reason for hiding this comment

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

it can be simplified with:

Decimal(output_str).as_integer_ratio()

Copy link
Contributor

Choose a reason for hiding this comment

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

actually it can be simplified even more. python class Fraction supports formats:

  • A/B Fraction("42/123").as_integer_ratio()
  • A (like Fraction("42").as_integer_ratio()
  • A.B (like Fraction("42.123").as_integer_ratio())

Copy link
Contributor

@twalen twalen left a comment

Choose a reason for hiding this comment

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

OK

@MasloMaslane MasloMaslane merged commit cd195e5 into sio2project:master Mar 20, 2024
2 checks passed
top-sekret pushed a commit to top-sekret/sioworkers that referenced this pull request Dec 2, 2024
* Result percentage changed to a fraction

* Fix typos

* Extend tests

* More tests

* More error checking

* Simplified result percentage string parsing.

* Added division by zero error handling.

* Added and changed tests.

* fix: added fraction package

* fixed attribute error

* fixed type error

* fixed tests

---------

Co-authored-by: Zonkil <[email protected]>

(cherry picked from commit cd195e5)
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