-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
re-usable component to show quantity with significant decimal digits #1244
Conversation
22b4a9e
to
d67c673
Compare
Codecov Report
@@ Coverage Diff @@
## main #1244 +/- ##
=======================================
Coverage 79.62% 79.62%
=======================================
Files 90 90
Lines 7209 7224 +15
=======================================
+ Hits 5740 5752 +12
- Misses 1469 1472 +3
Continue to review full report at Codecov.
|
d67c673
to
51b040d
Compare
I'm trying this PR with the example notebooks in a new conda environment and I'm getting NaNs in line analysis. I'm creating a subset in the spectrum viewer (in both cubeviz and specviz) and setting that as the spectral region in line analysis. |
* used in line analysis table * can pass the maximum number of decimal digits (which becomes the default if no uncertainty is passed) * if uncertainty is passed, both the value and uncertainty are rounded to the second significant digit in the uncertainties * might not be entirely perfect - javascript treatment of numbers can be a bit funny... but the full underlying floats are untouched via the API
51b040d
to
9480600
Compare
This should be fixed now. My local testing branch was forcing vue to re-compute the |
Works well in Specviz though! Is it not working the same in cubeviz because the spectrum does not have an uncertainty value? |
Ah, this is a case where the original specs aren't sufficient. We probably don't want to default to 5 (or 8) decimal places after all, but rather significant digits. These are showing as 0s because the underyling float is smaller than that. I'll try to rework the logic to work on significant digits (or decimals in scientific notation) instead. |
* if uncertainty is not provided, rounds to a fixed precision (default of 5, default of 8 in line analysis) * if uncertainty is provided, that is rounded to a precision of 2 digits, and the value is rounded to the same digit
Ok, I rewrote the logic entirely to be based on precision instead of number of decimal places and haven't managed to find a case where it breaks, but please do try! If this isn't robust enough... we may have to handle it on the python side, Javascript can be a pain to deal with numbers. |
Can you compare to the list of dictionaries storing the results ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it out and you are correct, the results on the backend are NaNs and 0s. I'll go ahead and approve since everything else is working as expected!
[{'function': 'Line Flux',
'result': '9.607043970686176e-07',
'uncertainty': '',
'unit': '1e-17 erg m / (Angstrom cm2 s)'},
{'function': 'Equivalent Width',
'result': '-1.6298725716548473e-09',
'uncertainty': '',
'unit': 'm'},
{'function': 'Gaussian Sigma Width',
'result': 'nan',
'uncertainty': '',
'unit': 'm'},
{'function': 'Gaussian FWHM',
'result': 'nan',
'uncertainty': '',
'unit': 'm'},
{'function': 'Centroid',
'result': '6.675966140764623e-07',
'uncertainty': '',
'unit': 'm'}]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into an Jesse's nan issue, but when I extracted the parameters, the line flux actually returns a value, which isn't showed in the UI (and as usual, Mosviz is the problem config again 😅). Thoughts @kecnry?
@duytnguyendtn - interesting case. The logic is choking because of the 0 uncertainty. How do we want to handle this case (perhaps display the default 8 digits... but do we show or hide the +/- 0... or is this an upstream issue in specutils that should not return a zero uncertainty)? |
I interpret 0 uncertainty as the same as not having an uncertainty. I would just drop the 0+/-, similar to how the centroid appears in the above screenshot. Maybe a PO is needed here? |
* treat as no uncertainty provided, fallback on default digits for value
I like that solution for now (and implemented it in the latest commit), and will open a follow-up ticket for investigating why the flux is returning 0 uncertainty in the first place. 🐱 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This pull request creates yet another re-usable component (used in the output from line analysis for now), to have the UI round quantities based on the uncertainty or a default precision. If an uncertainty is available, both the value and uncertainty are rounded to the second significant
decimaldigit in the uncertainties(currently no rounding is done for digits left of the decimal). Note that this might not be entirely perfect - javascript treatment of numbers can be a bit funny... but the full underlying floats are untouched via the API.Before and after screenshots in line analysis:
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.CHANGES.rst
?