Skip to content

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

tsmbland
Copy link
Collaborator

@tsmbland tsmbland commented Apr 14, 2025

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

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 96 lines in your changes missing coverage. Please review.

Project coverage is 91.82%. Comparing base (2ba3e14) to head (6ec15d6).

Files with missing lines Patch % Lines
src/metrics.rs 0.00% 48 Missing ⚠️
src/units.rs 0.00% 48 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@alexdewar alexdewar left a 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.

  1. unit_struct!(A) could also define multiplication ops for Dimensionless (both A * Dimensionless and Dimensionless * A) and division ops
  2. 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 like A / B = APerB and B * 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).

@tsmbland tsmbland changed the title Rough idea for strict enforcement of units LCOX calculation with strict enforcement of units Apr 23, 2025
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.

Add option to perform LCOX calculation
2 participants