Skip to content

handle nan in tools.golden_sect_DataFrame #1408

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 6 commits into from
Feb 17, 2022
Merged

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Feb 17, 2022

  • [ ] Closes #xxxx
  • I am familiar with the contributing guidelines
  • Tests added
  • [ ] Updates entries in docs/sphinx/source/reference for API changes.
  • [ ] Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for 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`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels and Milestone are assigned to the Pull Request and linked Issue.

Supplements #1089. See discussion.

@cwhanse cwhanse added this to the 0.9.1 milestone Feb 17, 2022
pvlib/tools.py Outdated

return func(df, 'V1'), df['V1']
func_result = func(df, 'V1')
Copy link
Member

Choose a reason for hiding this comment

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

This PR gets #1394 working again for me locally, so +1 for that. However I think this will still fail with a KeyError if either of upper or lower is all nans: in that case iterlimit will still be nan, so the while loop will not execute at all, causing df['V1'] to not exist when this line executes. I think the all-nan case is worth supporting: a ModelChain simulation of only nighttime is not particularly useful, but shouldn't throw an error IMHO.

Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

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

Not an expert about the context of this function but LGTM. Stickler is complaining still.

@cwhanse cwhanse merged commit b8f89b8 into pvlib:master Feb 17, 2022
@mikofski
Copy link
Member

I guess my preference long term would be to replace this with the SciPy Cython Optimize Zeros API brentq() function. Not having to maintain a math library seems preferable to me.

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