-
Notifications
You must be signed in to change notification settings - Fork 1
LCOX calculation with strict enforcement of units #481
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #481 +/- ##
==========================================
- Coverage 93.73% 91.82% -1.91%
==========================================
Files 36 38 +2
Lines 4627 4723 +96
Branches 4627 4723 +96
==========================================
Hits 4337 4337
- Misses 139 235 +96
Partials 151 151 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
It seems like this approach could work and there would be definite advantages to doing things this way. My main concern is that we might end up wanting more arithmetic operations, but then again, they probably wouldn't be that hard to add and realistically we're not doing much in the way of fancy maths anyway, so even a fairly basic set of operations would probably do us fine.
I think you could simplify the use of the macros a bit.
unit_struct!(A)
could also define multiplication ops forDimensionless
(bothA * Dimensionless
andDimensionless * A
) and division ops- You could define a separate macro for creating units that are two other kinds of units divided together, e.g.
unit_div_struct!(A, B, APerB)
, which would also define operations likeA / B = APerB
andB * APerB = A
etc.
That should make it more readable and easier to add new units (if we ever need to).
You could also define From<f64>
for Dimensionless
and vice versa as converting between these types is harmless (in contrast to other unit types).
Description
Please include a summary of the change and which issue is fixed (if any). Please also
include relevant motivation and context. List any dependencies that are required for
this change.
Fixes #171
Type of change
Key checklist
$ cargo test
$ cargo doc
Further checks