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

Handicaps refactor #78

Merged
merged 29 commits into from
Mar 5, 2024
Merged

Handicaps refactor #78

merged 29 commits into from
Mar 5, 2024

Conversation

jatkinson1000
Copy link
Owner

@jatkinson1000 jatkinson1000 commented Feb 23, 2024

OK, this has been a slog and I will need a bit of a break after, but here it is.
In the words of Dylan Beattie: https://www.youtube.com/watch?v=xCGu5Z_vaps

MR Checklist:

  • Source code updated to address issue
  • Style and formatting applied
  • Tests written to cover changes
  • Docstrings included/updated in code
  • Project documentation updated as necessary

Summary:

  • The handicaps code has been fully refactored into a class structure, with each scheme being a subclass of a base HandicapScheme class
  • Handicap table functionalities have also been brought inside a HandicapTable Class
  • A set of wrapper functions around the HandicapScheme classes have been written to provide easy access and preserve similar behaviour of the previous API.

This will close #2
This inadvertently also closes #60

TODO:

  • Update examples notebook
  • Add a function to HandicapTable to yield a string output for use elsewhere (archerycalculator).
  • Decide how best to add the specific documentation for each HandicapScheme subclass to the documentation.

@jatkinson1000 jatkinson1000 added the enhancement New feature or request label Feb 23, 2024
@jatkinson1000 jatkinson1000 self-assigned this Feb 23, 2024
@jatkinson1000
Copy link
Owner Author

jatkinson1000 commented Feb 23, 2024

@TomHall2020 and @LiamPattinson please do take a look and let me know your comments.
If you would be happy to review please let me know and I'll add you.
I'd suggest starting with the new docs from this MR which can be found here.

@TomHall2020
Copy link
Contributor

Yeah would be happy to review on this. Will pull down the fork and play with it interactively too, but the new public API does look way better (good riddance HcParams!)

Copy link
Contributor

@LiamPattinson LiamPattinson left a comment

Choose a reason for hiding this comment

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

Overall looking great, pretty much exactly what I had in mind. The only comments I have are really nitpicky.

archeryutils/handicaps/handicap_scheme_aa.py Outdated Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme_aa.py Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme.py Outdated Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme.py Outdated Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme.py Outdated Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme_aa.py Show resolved Hide resolved
archeryutils/handicaps/handicap_functions.py Show resolved Hide resolved
archeryutils/handicaps/handicap_functions.py Outdated Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme.py Show resolved Hide resolved
archeryutils/handicaps/handicap_scheme.py Outdated Show resolved Hide resolved
@TomHall2020
Copy link
Contributor

TomHall2020 commented Feb 23, 2024

Had to stop my review there, don't know if it was the diffs or my browser but the github web interface just started going nuts. Most of what I've picked up on is the implicit coupling of desc_scale to handicap system specific data in the base HandicapScheme class, should be fairly easy to fix. Otherwise absolutely way hapier with the API, I can build a round and get useful information on it in a REPL so much more easily than before

from archeryutils import Round, Pass, Target
from archeryutils import handicaps as hc

t = Target("5_zone", (48, "inch"), (80, "yards"))
p = Pass(30,t)
r = Round('Test', [p,p,p])

hc.score_for_round(r, 30, "AGB")
hc.handicap_from_score(700, r, "AGB")

Much more intuitive than the previous version and I appreciate the reduced imports as well. Even though I'd got familiar with the codebase by now, from a dev point of view the file layout now also feels more intuitive too.

@jatkinson1000
Copy link
Owner Author

@LiamPattinson @TomHall2020 I have updated the docs which was the last TODO from my end.
I believe I have also addressed the points raised above in review.

If I can get closure of those and an approving review I will merge this which should unblock a number of your PRs @TomHall2020 and bring us very close to completing #49.

Copy link

codecov bot commented Mar 3, 2024

Codecov Report

Attention: Patch coverage is 97.18004% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 97.66%. Comparing base (3d94e2b) to head (6d07d58).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
+ Coverage   96.07%   97.66%   +1.59%     
==========================================
  Files          24       28       +4     
  Lines        1426     1499      +73     
==========================================
+ Hits         1370     1464      +94     
+ Misses         56       35      -21     
Files Coverage Δ
archeryutils/__init__.py 100.00% <100.00%> (ø)
...utils/classifications/agb_field_classifications.py 100.00% <ø> (ø)
...tils/classifications/agb_indoor_classifications.py 100.00% <100.00%> (ø)
.../classifications/agb_old_indoor_classifications.py 100.00% <100.00%> (ø)
...ils/classifications/agb_outdoor_classifications.py 100.00% <100.00%> (ø)
...cheryutils/classifications/tests/test_agb_field.py 100.00% <ø> (ø)
...heryutils/classifications/tests/test_agb_indoor.py 100.00% <ø> (ø)
...utils/classifications/tests/test_agb_old_indoor.py 100.00% <ø> (ø)
...eryutils/classifications/tests/test_agb_outdoor.py 100.00% <ø> (ø)
archeryutils/handicaps/__init__.py 100.00% <100.00%> (ø)
... and 9 more

Copy link
Contributor

@TomHall2020 TomHall2020 left a comment

Choose a reason for hiding this comment

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

Looks good to me, fundamentally all the issues I had are addressed, the public api is much improved, and should be a clean foundation to work from in the future.

@TomHall2020 TomHall2020 mentioned this pull request Mar 4, 2024
@jatkinson1000
Copy link
Owner Author

OK, great.

If you are happy please could you do a review with "Approve" selected @TomHall2020?
(Go to Files Changed, select green review button, add a message and then select the "Approve" radio button instead of "Comment".)
That should then unlock it for me to merge (I put branch protection rules on now that there is more than just me opening PRs).

@TomHall2020
Copy link
Contributor

TomHall2020 commented Mar 5, 2024

If you are happy please could you do a review with "Approve" selected @TomHall2020? (Go to Files Changed, select green review button, add a message and then select the "Approve" radio button instead of "Comment".) That should then unlock it for me to merge (I put branch protection rules on now that there is more than just me opening PRs).

I've reviewed and approved already, but from the status bar below it looks like the repo is set to require an approving review from someone with write access, so that might be the issue you're having.

@LiamPattinson
Copy link
Contributor

I've added my approval and I'm seeing the same issue: at least 1 approving review is required by reviewers with write access.

@jatkinson1000 jatkinson1000 merged commit 860c93b into main Mar 5, 2024
12 checks passed
@jatkinson1000
Copy link
Owner Author

Thanks folks - feels great to get this one finally checked off!

@TomHall2020 if you can update your open PRs to use this (I know you already rebased one) then hopefully they can follow soon.

@jatkinson1000 jatkinson1000 deleted the handicap-refactor branch March 5, 2024 15:44
@jatkinson1000 jatkinson1000 mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make some handicap_functions methods private HcParams leads to a complicated interface
3 participants