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

Pretty print 'long' units with long prefixes #309

Merged
merged 7 commits into from
Feb 6, 2024

Conversation

do-you-dare
Copy link
Contributor

This work is related to #133. Any feedbacks are welcome.

I've run the test case on the issue description and it seems to work as expected. cargo test passes with no errors and I've added a roundtrip check as required as well.

If you want, I can squash or change the commits to better fit the project as well

We plan to use this to signal that some units don't allow short
prefixes, but as of now, I've just made the least ammount of changes to
keep the current behavior and have the tests running.
Before this, we had:

```
>>> @metric_prefixes
unit points

  @metric_prefixes
  unit points

>>> megapoints

  megapoints

    = 1 Mpoints
```

Now we have:

```
>>> @metric_prefixes
unit points

  @metric_prefixes
  unit points

>>> megapoints

  megapoints

    = 1 megapoints
```

I've also added a roundtrip test.
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you very much! Only a few minor comments.

Before this, it accepted a string and a AcceptsPrefix that were used to
construct a CanonicalName internally.

This also applies fixes suggested on the PR review [1], such as
AcceptsPrefix inconsistencies on tests, code duplication on
get_canonical_unit_name.

[1]:sharkdp#309
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you

@sharkdp
Copy link
Owner

sharkdp commented Feb 6, 2024

Oh, hold on. This isn't actually fixed completely.

Try typing megabarn, and it will result in Mbarn. I'm currently looking into it.

@sharkdp sharkdp merged commit 7ace747 into sharkdp:master Feb 6, 2024
15 checks passed
sharkdp pushed a commit that referenced this pull request Feb 6, 2024
Before this, it accepted a string and a AcceptsPrefix that were used to
construct a CanonicalName internally.

This also applies fixes suggested on the PR review [1], such as
AcceptsPrefix inconsistencies on tests, code duplication on
get_canonical_unit_name.

[1]:#309
@triallax
Copy link
Contributor

triallax commented Feb 6, 2024

Thanks for the good work!

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.

3 participants