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

Idea: have a fallback_ndigits option #177

Open
jagerber48 opened this issue Jul 28, 2024 · 1 comment
Open

Idea: have a fallback_ndigits option #177

jagerber48 opened this issue Jul 28, 2024 · 1 comment

Comments

@jagerber48
Copy link
Owner

Right now for value/uncertainty formatting sciform first looks to the uncertainty to determine the decimal place to which the value and uncertainty should be rounded and displayed. sciform succeeds if the uncertainty is non-zero and finite. If the uncertainty is zero or non-finite (recall non-finite includes nan) then it falls back to the value to determine the decimal place to which to round. Typically sciform is configured to round to one or two digits of uncertainty, or use the PDG rounding convention. This means the value will be rounded the same. However, this is a little strange because, for example, the PDG rules are meant to apply to uncertainty, not values.

This issue proposes a new option called fallback_ndigits which instructs sciform how to behave in this fallback scenario. Options would be

  • An integer indicating the number of sig figs to which to round (or the number of digits past the decimal point if Support decimal place rounding for value/uncertainty pairs. #170 is implemented)
  • AutoDigits, show as many digits as necessary for the float to round trip.
  • NoFallback, in this mode the regular ndigits option is used.
  • None, use the global default setting
@jagerber48
Copy link
Owner Author

More thoughts on this:

  • It's not so strange for PDG rounding to be applied to values alone. It's just a rounding algorithm that outputs to round to 1 or 2 sig figs.

Without any such fallback feature the user could easily write two of their own Formatters, detect if their uncertainty is zero or non-finite and select which formatter to use based on that.
One general way this approach could be wrapped into sciform is to have an entire fallback formatter. In the event the uncertainty is invalid the fallback formatter could be merged into the main formatter and the result could be used.
It's an open question which formatter should be used if both the uncertainty and value are invalid.

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

No branches or pull requests

1 participant