-
Notifications
You must be signed in to change notification settings - Fork 2
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
Targetdiameter #52
Targetdiameter #52
Conversation
Just saw your message on the issue after posting this, haven't added the units option to Pass yet but would be trivial to add if you want it still. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting this @TomHall2020, and thanks for getting involved with the project. Progress looks good so far.
I particularly like the condensing of the possible units terms which makes things much cleaner!
I have picked out a few specific comments in the code below, but more generally:
- I would like to have inches as an option (Worcester and IFFA etc.) if you could add this.
- A knock on from this is that it would probably be a good idea to update the round loader to accept a non-default diameter unit. I could look at this later however if you want.
- it should be possible to pass distance units to the
Pass
constructor as an optional argument (as you already mention in a comment above).
I'm getting a few spurious additional blank lines and re-arranged imports etc. Are you using an 'intelligent' editor/IDE that has automatically done this?
This partially reverts commit 5dc07fc.
…s constructor to Target
Updated with Inches support, passthrough of units and I think most of the comments addressed. I can clean that up either by
RE my idea on the call signature for targe and packaging lengths up into their own object, just beacuse if you did want to go down that road then here option 1 is best in this PR and doing that change makes most sense done seperately? Although appreicate its another breaking change to the signature. Otherwise happy to do 1 or 2 and close this off. |
Packaged all conversion operations, alias references into single class that can be imported from constants
Had another look at this, if you check the latest two commits. First implements namespacing the conversions into a dictionary and getting rid of individual constants Second takes it a step further and packages everything together into a |
archeryutils/rounds.py
Outdated
if pass_i.native_dist_unit == "yard" | ||
else pass_i.distance | ||
) | ||
dist = Length.from_metres(pass_i.distance, pass_i.native_dist_unit) | ||
if dist > max_dist: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While checking the change here noticed a bug, max_distance is comparing across units. A round with mixed distance units can give the wrong result here (eg 75m > 80y, but 80 > 70). Not common, but will come up for anyone making custom rounds, or potentially in IFAA where feet and yards are mixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can include a test and fix in next commits, assuming this was undesired behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spot, yes this should give the longest distance irrespective of unit of measurement.
Fix appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, like the idea of a Length
class. Couple of thoughts on the finer implementation that I will add in-code comments for.
Also dropped a comment on the 'magnitude and units' conversation.
Finally - you may want to run black on the code pre-submission.
Think this should be pretty much there now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TomHall2020 this is amazing!
I added a couple of commits for nits (standardise 'diam' to 'diameter') and to update the examples notebook but I agree this is all ready to go 🚀
Thanks again for contributing, it's great to see my code being used and others take an interest and you are welcome to contribute again in future. You write well, but also apply good SE principles, and hopefully we both learnt some new things. 😄
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
+ Coverage 95.07% 95.38% +0.31%
==========================================
Files 22 23 +1
Lines 1218 1301 +83
==========================================
+ Hits 1158 1241 +83
Misses 60 60
|
Closes #27
Set default target diameter units to cm
Updates tests and load_rounds functionality
Round data files all seem to specify target face sizes in cm already so enforcing this as the default unit makes sense.
Aliases for distance units moved into the constants file as it was getting out of hand and avoiding repitition, choice of conversion constants handled in the branching points in
Target.__init__
, this could perhaps be handled more elegantly if more units need to be supported in the future but didn't want to change more than necessary for now.