Repository navigation
MNT: Stop using our own catch_warnings and raises #10504
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
164c1ba
MNT: Replace catch_warnings in erfa tests
pllim 2718912
MNT: Replace catch_warnings in config tests
pllim 10391d2
MNT: Replace catch_warnings in coordinates tests.
pllim faf20ec
MNT: Replace catch_warnings in io.ascii tests
pllim d3ae2df
MNT: Remove catch_warnings from test guide
pllim 3f1fc48
MNT: Remove catch_warnings from units tests.
pllim d5504cc
MNT: Remove catch_warnings from wcsaxes tests
pllim 089626d
MNT: Remove catch_warnings from utils iers and decorators
pllim 9748b1b
MNT: Remove catch_warnings from utils data
pllim 51a59b4
Fix test failure seen in image-tests-mpl222
pllim 60146b5
More fixes for coordinates, table, wcsapi
pllim ce7b5c8
MNT: Remove catch_warnings and raises from io.fits
pllim 5166ade
MNT: Remove catch_warnings from io.misc
pllim 70ae5aa
MNT: Remove catch_warnings and raises from io.votable
pllim 0328481
MNT: Remove catch_warnings and raises from modeling
pllim f193be1
MNT: Remove catch_warnings from nddata
pllim d14d246
MNT: Remove catch_warnings from stats
pllim a7dc955
MNT: Remove catch_warnings from table tests
pllim a89eda3
MNT: Remove catch_warnings from logger tests
pllim 0fc7831
MNT: Remove catch_warnings from time tests
pllim a4ee90a
MNT: Remove catch_warnings and raises from units tests
pllim ad61c7d
MNT: Remove outdated imports
pllim fa2dd7b
DOC: Also add a note about raises
pllim 6b11398
Fix typo and CI error
pllim f467c4a
MNT: Remove catch_warning and raises from wcs tests
pllim 8301175
Fix test_oversize_unicode in io.votable
pllim 0c348c6
Delete duplicate test_write_nopath in test_hdf5
pllim 73b94a4
Apply @mhvk comments for modeling, table, utils tests
pllim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| from astropy.coordinates.builtin_frames.utils import get_jd12 | ||
| from astropy.coordinates import EarthLocation | ||
| from astropy.coordinates import SkyCoord | ||
| from astropy.tests.helper import catch_warnings | ||
| from astropy import _erfa as erfa | ||
| from astropy.utils import iers | ||
| from .utils import randomly_sample_sphere | ||
|
|
@@ -164,26 +163,19 @@ def test_future_altaz(): | |
| if hasattr(utils, '__warningregistry__'): | ||
| utils.__warningregistry__.clear() | ||
|
|
||
| with catch_warnings() as found_warnings: | ||
|
|
||
| location = EarthLocation(lat=0*u.deg, lon=0*u.deg) | ||
| t = Time('J2161') | ||
|
|
||
| SkyCoord(1*u.deg, 2*u.deg).transform_to(AltAz(location=location, obstime=t)) | ||
| location = EarthLocation(lat=0*u.deg, lon=0*u.deg) | ||
| t = Time('J2161') | ||
|
mhvk marked this conversation as resolved.
Resolved
|
||
|
|
||
| # check that these message(s) appear among any other warnings. If tests are run with | ||
| # --remote-data then the IERS table will be an instance of IERS_Auto which is | ||
| # assured of being "fresh". In this case getting times outside the range of the | ||
| # table does not raise an exception. Only if using IERS_B (which happens without | ||
| # --remote-data, i.e. for all CI testing) do we expect another warning. | ||
| messages_to_find = ["Tried to get polar motions for times after IERS data is valid."] | ||
| with pytest.warns(AstropyWarning, match=r"Tried to get polar motions for " | ||
| "times after IERS data is valid.*") as found_warnings: | ||
| SkyCoord(1*u.deg, 2*u.deg).transform_to(AltAz(location=location, obstime=t)) | ||
|
|
||
| if isinstance(iers.earth_orientation_table.get(), iers.IERS_B): | ||
| messages_to_find.append("(some) times are outside of range covered by IERS table.") | ||
|
|
||
| messages_found = [False for _ in messages_to_find] | ||
| for w in found_warnings: | ||
| if issubclass(w.category, AstropyWarning): | ||
| for i, message_to_find in enumerate(messages_to_find): | ||
| if message_to_find in str(w.message): | ||
| messages_found[i] = True | ||
| assert all(messages_found) | ||
| messages_found = ["(some) times are outside of range covered by IERS " | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mhvk , I tried to simplify the logic here but you might want to double check. |
||
| "table." in str(w.message) for w in found_warnings] | ||
| assert any(messages_found) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.