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

Fix deprecations as warnings #738

Merged
merged 44 commits into from
Jun 19, 2023
Merged

Conversation

matteobachetti
Copy link
Member

@matteobachetti matteobachetti commented Jun 8, 2023

Resolve #735

enable_deprecations_as_warnings does not exist anymore in astropy. The recommended way is to now let all warnings be errors, unless the ones that are ignored or caught properly.

This PR eliminates the call to enable_deprecations_as_warnings, and contextually, changes the code to be much more robust in catching harmful warnings.

My PR is basically a bunch of:

  • with pytest.warns(..., match="...."): in tests,
  • ignore:....:UserWarning in setup.cfg
  • some reordering of warnings after errors so that they did not both get raised
  • subtle issues like r""" instead of simple """ in docstrings (this gave a bunch of warnings about LaTeX commands interpreted as escapes that did not get caught)
  • One eliminated Examples section from a docstring because it raised warnings that could not get caught
  • A bunch of options (e.g. legacy=True) added to tests so that they did not trigger a warning.

All in all, it was a good exercise. The code did throw far too many warnings, and some of them were actually either relevant or safe to eliminate.

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #738 (8383ad4) into main (23a692c) will decrease coverage by 0.04%.
The diff coverage is 93.54%.

@@            Coverage Diff             @@
##             main     #738      +/-   ##
==========================================
- Coverage   97.15%   97.12%   -0.04%     
==========================================
  Files          42       42              
  Lines        7872     7884      +12     
==========================================
+ Hits         7648     7657       +9     
- Misses        224      227       +3     
Impacted Files Coverage Δ
stingray/fourier.py 99.74% <ø> (ø)
stingray/spectroscopy.py 82.22% <ø> (ø)
stingray/modeling/parameterestimation.py 86.03% <83.33%> (-0.01%) ⬇️
stingray/crossspectrum.py 98.21% <100.00%> (-0.28%) ⬇️
stingray/deadtime/fad.py 99.39% <100.00%> (ø)
stingray/io.py 98.50% <100.00%> (+<0.01%) ⬆️
stingray/modeling/posterior.py 93.51% <100.00%> (+0.10%) ⬆️
stingray/multitaper.py 99.15% <100.00%> (ø)
stingray/pulse/pulsar.py 98.67% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@dhuppenkothen dhuppenkothen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of work in here! Thanks for doing this! Looks good to me.

@matteobachetti matteobachetti added this pull request to the merge queue Jun 19, 2023
Merged via the queue into main with commit 0766abf Jun 19, 2023
@matteobachetti matteobachetti deleted the fix_deprecation_as_warning branch September 22, 2023 09:36
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.

Notice: You might be using enable_deprecations_as_exceptions that is removed in astropy v6
2 participants