Warnings display twice in Jupyter notebooks
See original GitHub issueDescription
Previously I was seeing this behavior in both a Jupyter notebook context and in an interactive python session in a terminal, but pulling the most recent main
branch updates and doing a dev install seems to have fixed the latter case. I’m still seeing duplicate warning messages (with minor syntax differences between the two) when I use astropy in a notebook, for example:
WARNING: No observer defined on WCS, SpectralCoord will be converted without any velocity frame change [astropy.wcs.wcsapi.fitswcs]
WARNING:astropy:No observer defined on WCS, SpectralCoord will be converted without any velocity frame change
I imagine this has something to do with the way the AstropyLogger
is catching and displaying warnings.warn
calls.
Steps to Reproduce
A quick snippet to trigger a warning:
import numpy as np
import astropy.units as u
flux = np.ones(3) * u.Unit("1E-17 erg/s/cm^2/Angstrom")
This displays two warnings:
WARNING: UnitsWarning: '1E-17 erg/s/cm^2/Angstrom' contains multiple slashes, which is discouraged by the FITS standard [astropy.units.format.generic]
WARNING:astropy:UnitsWarning: '1E-17 erg/s/cm^2/Angstrom' contains multiple slashes, which is discouraged by the FITS standard
System Details
Checking that my notebook is actually using the dev version of astropy:
Python 3.8.8 (default, Feb 24 2021, 13:46:16) Numpy 1.20.1 astropy 4.2.dev2287+g8615fc8ca
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Warnings module prints part of warning twice - Stack Overflow
Try this: warnings.warn("The specified directory is not empty, and does not " "appear to contain a pipeline we can update. Exiting.
Read more >Warnings are displayed twice · Issue #5592 - GitHub
Whenever a warning is emitted, the message is shown twice because the logger also prints this information to the screen.
Read more >warnings — Warning control — Python 3.11.1 documentation
The warnings filter controls whether warnings are ignored, displayed, or turned into errors (raising an exception). Conceptually, the warnings filter maintains ...
Read more >Troubleshooting — jupyter_contrib_nbextensions 0.5.0 ...
This can lead, for example, to having all the nbextensions listed twice on the configurator page. Extensions Not Loading for Large Notebooks¶. If...
Read more >How To Set Up Jupyter Notebook with Python 3 on Ubuntu ...
This tutorial will walk you through setting up Jupyter Notebook to run from an Ubuntu 18.04 server, as well as teach you how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s exactly where I had just started my investigation. Thanks for the tips!
Ah, I just did a pull not fetch. I have
astropy 4.3.dev1123+g8615fc8ca
after fetching the tags.Upon further inspection it looks like you’re correct about this originating somewhere other than astropy, I’ll close this issue and investigate further. I suspect it’s actually a specutils issue…