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 deprecation warning for truth value of an empty array [all tests ci] #1450

Merged

Conversation

ctuguinay
Copy link
Collaborator

@ctuguinay ctuguinay commented Feb 16, 2025

Fixes deprecation warning which arose in the azfp6 parser when checking valid parameters for temperature and tilt which was discovered in #1444:

Warning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use array.size > 0 to check that an array is not empty.

@ctuguinay ctuguinay marked this pull request as ready for review February 16, 2025 02:41
@ctuguinay ctuguinay self-assigned this Feb 16, 2025
@ctuguinay ctuguinay added the bug Something isn't working label Feb 16, 2025
@ctuguinay ctuguinay added this to the v0.9.2 milestone Feb 16, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.32%. Comparing base (9f56124) to head (2e24e75).
Report is 186 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1450      +/-   ##
==========================================
+ Coverage   83.52%   85.32%   +1.80%     
==========================================
  Files          64       72       +8     
  Lines        5686     6583     +897     
==========================================
+ Hits         4749     5617     +868     
- Misses        937      966      +29     
Flag Coverage Δ
unittests 85.32% <100.00%> (+1.80%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ctuguinay ctuguinay modified the milestones: v0.9.2, v0.9.1 Feb 16, 2025
@ctuguinay ctuguinay marked this pull request as draft February 17, 2025 17:29
@ctuguinay ctuguinay changed the title Fix deprecation warning for truth value of an empty array Fix deprecation warning for truth value of an empty array [all tests ci] Feb 17, 2025
@ctuguinay ctuguinay closed this Feb 17, 2025
@ctuguinay ctuguinay reopened this Feb 17, 2025
@ctuguinay ctuguinay closed this Feb 17, 2025
@ctuguinay ctuguinay reopened this Feb 17, 2025
@ctuguinay ctuguinay marked this pull request as ready for review February 17, 2025 18:41
@ctuguinay ctuguinay requested a review from leewujung February 17, 2025 18:42
@ctuguinay
Copy link
Collaborator Author

@leewujung This one is ready for review

@leewujung
Copy link
Member

Since the one fixed is under parse_azfp6 which I think came from parse_azfp, I took a look there too and found the same _test_valid_params function there. This repetition is not supposed to be like this, but it is part of the unfinished #1301 and #1323. I'll push the same change as what you had for the azfp counterpart.

Also, I think the condition you tested for should output False? Since in this case, self.parameters[[] does not contain valid parameters? I'll push this change too and you could review.

@leewujung
Copy link
Member

leewujung commented Feb 18, 2025

Actually, I was wrong, the parameters were saved differently in azfp and azfp6 format.
In azfp, if some parameters are missing, the values are set to 0.
In azfp6, if some parameters are missing, the values simply do not exist.
So @ctuguinay you changes made sense.

The only thing I changed was to go from True to False.

I am not sure if the below block is still needed -- seems better to remove?

if all([np.isclose(self.parameters[p], 0) for p in params]):
    return False

@leewujung leewujung modified the milestones: v0.9.1, v0.10.0 Feb 18, 2025
@leewujung
Copy link
Member

Oops I messed this up. Will look again tomorrow.

@leewujung
Copy link
Member

Ok, turns out that this is a bug from #1323 that the parameter checking was somehow moved to before the XML part of the file is parsed in ParseAZFP6 (it was the correct order in ParseAZFP). With that fixed, the scenario that produces the warning should never happen.

Let me know what you think.

@ctuguinay
Copy link
Collaborator Author

@leewujung Ah good catch. I double checked and in no case do we end up with an empty array. I'll squash merge this now.

@ctuguinay ctuguinay merged commit 9e49248 into OSOceanAcoustics:main Feb 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants