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 code that raises new numpy deprecation warnings #1308

Merged
merged 5 commits into from
Jun 26, 2023

Conversation

bhazelton
Copy link
Member

@bhazelton bhazelton commented Jun 22, 2023

Description

Changes:

  • Fixed a bunch of places that produced new DeprecationWarnings with numpy 1.25. I think that a few of these were real bugs.
  • Improve check_warnings to give the file and line number where warnings occur to help with debugging.
  • Don't issue a warning in efield to beam when fixing auto pols to be real if imaginary values are very small (i.e. caused by numerical precision issues). We started getting a bunch of these warnings when we didn't use to.
  • Made some hard to read one-line if statements in utility methods multiline. This resulted in a drop in coverage because we haven't set branch=True for coverage (see Check for coverage on all branches #1309). So I added some tests to cover all the branches.
  • Made a new conda environment for python 3.11. This is needed because we can't get h5py>=3.9 to resolve with all the other dependencies in python 3.11. We need h5py>=3.9 if we have numpy>=1.25 so we don't get flooded by deprecation warnings. So in the new env for 3.11 I restricted numpy to less than 1.25. This should be reverted in the future (Revert restriction on numpy<1.25 for python == 3.11 #1310).

Motivation and Context

Fix CI errors due to new numpy deprecation warnings.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change (documentation changes only)
  • Version change
  • Build or continuous integration change

Checklist:

Bug fix checklist:

  • My fix includes a new test that breaks as a result of the bug (if possible).
  • All new and existing tests pass.
  • I have updated the CHANGELOG.

@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Merging #1308 (cf37631) into main (986976c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1308   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          36       36           
  Lines       20064    20091   +27     
=======================================
+ Hits        20048    20075   +27     
  Misses         16       16           
Impacted Files Coverage Δ
pyuvdata/utils.py 100.00% <100.00%> (ø)
pyuvdata/uvbeam/mwa_beam.py 100.00% <100.00%> (ø)
pyuvdata/uvbeam/uvbeam.py 100.00% <100.00%> (ø)
pyuvdata/uvcal/fhd_cal.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/mir.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/mir_meta_data.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/uvdata.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/uvfits.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 986976c...cf37631. Read the comment docs.

@bhazelton bhazelton force-pushed the fix_new_numpy_warnings branch from aacc3a5 to 366d5f9 Compare June 23, 2023 00:07
Copy link
Member

@mkolopanis mkolopanis left a comment

Choose a reason for hiding this comment

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

Looking good to me. I think my only question is why are we adding a lot of [0] indices in places? Did we used to have length 1 dimensions that we are collapsing?

@bhazelton
Copy link
Member Author

I think my only question is why are we adding a lot of [0] indices in places? Did we used to have length 1 dimensions that we are collapsing?

Yes. Numpy now complains about converting single element arrays to scalars:
Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

Copy link
Contributor

@steven-murray steven-murray left a comment

Choose a reason for hiding this comment

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

Just the one small typo

pyuvdata/tests/test_utils.py Outdated Show resolved Hide resolved
@bhazelton bhazelton merged commit d4845e3 into main Jun 26, 2023
@bhazelton bhazelton deleted the fix_new_numpy_warnings branch June 26, 2023 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants