climate_indices icon indicating copy to clipboard operation
climate_indices copied to clipboard

Bug in eto_hargreaves function

Open njdepsky opened this issue 1 year ago • 1 comments

Line 316 of eto.py in the eto_hargreaves() function should compare the sizes of the three input arrays, but only includes ".size" on the first boolean argument, resulting in an error when running function.

Current syntax: if daily_tmin_celsius.size != daily_tmax_celsius != daily_tmean_celsius:

Correct syntax: if daily_tmin_celsius.size != daily_tmax_celsius.size != daily_tmean_celsius.size:

Perhaps this wasn't an issue with certain dependency versions, but on python 3.12.8 I'm getting an error: "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

njdepsky avatar Feb 26 '25 16:02 njdepsky

Please submit this in a PR. Thanks for your help!

monocongo avatar May 28 '25 14:05 monocongo

This issue has been resolved by commit ed7c8f0.

The syntax error on line 314 (formerly 316) in eto.py has been corrected:

Before:

if daily_tmin_celsius.size != daily_tmax_celsius != daily_tmean_celsius:

After:

if not (daily_tmin_celsius.size == daily_tmax_celsius.size == daily_tmean_celsius.size):

The fix properly applies .size to all three array comparisons, eliminating the "truth value of an array with more than one element is ambiguous" error.

This was addressed as part of a broader fix for issue #578, which also corrected missing reshape_to_2d() calls for the tmin and tmax arrays in the Hargreaves calculation.

Thank you @njdepsky for reporting this issue!

monocongo avatar Dec 24 '25 00:12 monocongo