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

Adding method to specify floating-point precision #552

Closed
wants to merge 3 commits into from

Conversation

cloppingemu
Copy link

Addresses #485

Precision can now be specified for percent, per_sec, elapsed_precise and eta_precise. Default precision values for percent, per_sec, elapsed_precise and eta_precise are 0, 4 (previous default), 0 and 0 respectively.

Precision can specified by the - separator as percent:-1 or per_sec:-2.

@djc
Copy link
Collaborator

djc commented Jun 25, 2023

I'm actually no longer sure I'm interested in adding a feature for this. This breaks compatibility, uses an unintuitive marker character (-, presumably since . is already used for the alternate template style?) and we now have support for custom ProgressTracker instances where you can fully customize the desired behavior.

Is there something we can do to make using a custom ProgressTracker easier for this use case?

@cloppingemu
Copy link
Author

Fair enough.

Issue with the marker was unavoidable because of the exisiting use of the more obvious choice. Open to suggestions for choice of character if we decide to merge in some version of the proposed changes.

I'm also surprised it is breaking compatibility. I'll have to have have a look at the CI actions.

I'll have a look at ProgressTracker and if it is easy and self-contained enough we could MAYBE just add an example for it instead.

@djc
Copy link
Collaborator

djc commented Jun 26, 2023

It's breaking because you added a field to FormattedDuration and HumanFloatCount.

I really don't want to add any more examples -- there are too many already. However, better documentation for ProgressTracker is probably warranted -- I don't think it's very discoverable right now.

@cloppingemu
Copy link
Author

Would agree with

better documentation for ProgressTracker is probably warranted -- I don't think it's very discoverable right now.

Just going through the style.rs now to see how ProgressTracker could be used to customize the printed message. I'll close this PR in the meantime. I'll be back with another using ProgressTracker.

djc pushed a commit that referenced this pull request Feb 8, 2024
The existing `{percent}` is rendered as an integer, which means it is not very useful for large data sets, as it rarely changes.

I suggest adding a new `{percent_precise}` (a non-breaking change?) that would render it with additional precision. For example, 3 fraction digits, as demonstrated by the test added here.

An earlier proposal to add precision to variables was rejected (#552), and AFAIK, there is no way to customize this without taking over rendering.

I think it would work well with existing variables like `elapsed_precise`, `eta_precise`.

Thanks for considering!
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.

None yet

2 participants