BUG: fix dirint KeyError with scalar inputs on pandas >= 2.0#2752
BUG: fix dirint KeyError with scalar inputs on pandas >= 2.0#2752Omesh37 wants to merge 9 commits into
Conversation
|
Updated the PR based on your feedback:
All 9 dirint tests pass locally. Please let me know if anything needs adjusting. |
RDaxini
left a comment
There was a problem hiding this comment.
I don't think the test failure is related to the changes in this PR
Ya it is related to failing test of test_singlediode_precision function in test_singlediode.py. Thank You :) |
echedey-ls
left a comment
There was a problem hiding this comment.
Nice PR @Omesh37 . Two minor comments down below.
5614b98 to
242830c
Compare
| Global Horizontal to Direct Normal Insolation", Technical Report No. | ||
| SERI/TR-215-3087, Golden, CO: Solar Energy Research Institute, 1987. | ||
| """ | ||
|
|
There was a problem hiding this comment.
Let's add a check for data length here.
Suggest
if len(times)<2:
raise ValueError('The DIRINT model requires at least two times')
We want to add a test to confirm that the error gets raised.
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
|
Fixed the Test updated to cover both cases:
|
Closes #2751
Description
pvlib.irradiance.dirintcrashed withKeyError: 'cannot use a single bool to index into setitem'when called with scalar inputs on pandas >= 2.0.In
_dirint_bins, scalar inputs likesolar_zenith=90cause comparisons such as(zenith >= 0) & (zenith < 25)to return a plain Pythonbool. pandas >= 2.0 treats scalar bools as label lookups onsetitem, raisingKeyError.Fix: Convert all four scalar-or-array inputs to
pd.Seriesat the top of_dirint_bins, ensuring boolean masks are always a booleanSeries.Checklist
docs/sphinx/source/whatsnew