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

fix for #307 #308

Merged
merged 8 commits into from
Aug 29, 2023
Merged

fix for #307 #308

merged 8 commits into from
Aug 29, 2023

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Aug 28, 2023

Change the order of to_string processing for meters and seconds to ma…ke some units containing combinations of those units work better.

Fix Issue #307.

Comment on lines +447 to +451
auto speedUnit = unit_from_string("mm/s");
EXPECT_EQ(to_string(speedUnit), "mm/s");

auto accUnit = unit_from_string("mm/s^2");
EXPECT_EQ(to_string(accUnit), "mm/s^2");
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked if these are the only examples, or is this part of a wider class of regressions that was introduced recently?

For example, km/s currently also formats as kHz*m, is this also fixed by the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The cause of this issue is a combination of two things. The first being a check taking a single base unit away from the unit, and 'm' was first in the list. so the remaining portions of the unit were then converted in isolation and since 1/s=Hz it also adds any prefix, by swapping the order to dealing with 's' first it takes care combinations of 'm' and 's' a bit better. So as best as I can tell the only types of unit this issue is affecting is combinations of 'meter' and 'second' so yes it also fixes fixes km/s. and gray being m^2/s^2 is a bit of quirk as well, that comes from handling meters in this fashion before s^2 so adding that check first solves that issue as well.

@phlptp phlptp merged commit a99841e into main Aug 29, 2023
36 checks passed
@phlptp phlptp deleted the meters_second_fix branch August 29, 2023 21:44
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.

2 participants