Repository navigation
Conversation
With scalar inputs, Python's ** operator returns a complex number for a negative base, and the following comparison raises TypeError instead of returning NaN as documented. Use np.power, which returns NaN.
Hey @Dukotah! 🎉Thanks for opening your first pull request! We appreciate your If AI is used for any portion of this PR, you must vet the content Finally, be sure the PR description includes the PR |
Member
|
closing because there's no linked issue with an agreed upon solution... nor is it a real world problem. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
docs/sphinx/source/whatsnewfor all changes. Includes link to the GitHub Issue with:issue:`num`or this Pull Request with:pull:`num`. Includes contributor name and/or GitHub username (link with:ghuser:`user`).The
windspeed_powerlawdocstring says it returns NaN when the reference height or wind speed is negative. That works for arrays and Series, but with plain scalars it raises instead:For Python floats,
(-0.2) ** 0.2gives a complex number rather than NaN, and thewind_speed < 0check right after can't compare a complex number.The fix computes the ratio with
np.power, which gives NaN for a negative base no matter the input type. I put it insidenp.errstate(invalid='ignore')because NaN is the documented result there, so the warning isn't useful.Tested with a new parametrized scalar test (negative height, negative wind speed, normal case). The negative-height case fails on main with the TypeError above and passes with the change. All of
tests/test_atmosphere.pypasses.Dukotah