Fix Fuentes int input truncation by forcing float dtype #2618
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.
Closes #2608
Summary
This PR fixes a dtype-dependent bug in
pvlib.temperature.fuenteswhere integerpoa_globalinputs could lead to truncated module temperatures and slightly different results compared to float inputs with the same numeric values.Changes
In
pvlib.temperature.fuentes:tmod_array = np.zeros_like(poa_global)totmod_array = np.zeros_like(poa_global, dtype=float)so internal temperature calculations always use a float dtype.In
tests/test_temperature.py:test_fuentes_int_float_consistency, which callsfuenteswith both integer and floatpoa_globalseries (same values, datetime index) and asserts that the results match within floating-point tolerance.Rationale
Previously, when
poa_globalwas an integer Series,tmod_arraywas also integer, so intermediate temperatures such as321.19 Kwere truncated to321when stored. Converting to Celsius (tmod_array - 273.15) produced a different value than for float inputs.This change ensures that physically identical inputs (
100vs100.0) produce identical Fuentes outputs.Testing
pytest tests/test_temperature.py::test_fuentes -vpytest tests/test_temperature.py::test_fuentes_int_float_consistency -v