Skip to content

Commit 605e4d7

Browse files
Fix Fuentes int input truncation by forcing float dtype
1 parent 03fb340 commit 605e4d7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pvlib/temperature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
884884
windmod_array = wind_speed * (module_height/wind_height)**0.2 + 1e-4
885885

886886
tmod0 = 293.15
887-
tmod_array = np.zeros_like(poa_global)
887+
tmod_array = np.zeros_like(poa_global, dtype = float)
888888

889889
iterator = zip(tamb_array, sun_array, windmod_array, tsky_array,
890890
timedelta_hours)

tests/test_temperature.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,21 @@ def test_fuentes(filename, inoct):
260260
assert night_difference.max() < 6
261261
assert night_difference.min() > 0
262262

263+
def test_fuentes_int_float_consistency():
264+
"""Test that int and float inputs give identical results after dtype fix."""
265+
index = pd.date_range('2020-01-01', periods=3, freq='h')
266+
267+
poa_int = pd.Series([800, 800, 800], index=index, dtype=int)
268+
poa_float = pd.Series([800.0, 800.0, 800.0], index=index)
269+
temp_air = pd.Series([25.0, 25.0, 25.0], index=index)
270+
wind_speed = pd.Series([1.0, 1.0, 1.0], index=index)
271+
272+
out_int = temperature.fuentes(poa_int, temp_air, wind_speed, noct_installed=45)
273+
out_float = temperature.fuentes(poa_float, temp_air, wind_speed, noct_installed=45)
274+
275+
# Check outputs are identical within floating-point tolerance
276+
pd.testing.assert_series_equal(out_int, out_float, check_exact=False, rtol=1e-10)
277+
263278

264279
@pytest.mark.parametrize('tz', [None, 'Etc/GMT+5'])
265280
def test_fuentes_timezone(tz):

0 commit comments

Comments
 (0)