Skip to content

Conversation

@kumaradityaapril
Copy link

@kumaradityaapril kumaradityaapril commented Dec 10, 2025

Closes #2608

Summary

This PR fixes a dtype-dependent bug in pvlib.temperature.fuentes where integer poa_global inputs could lead to truncated module temperatures and slightly different results compared to float inputs with the same numeric values.

Changes

  • In pvlib.temperature.fuentes:

    • Changed tmod_array = np.zeros_like(poa_global) to tmod_array = np.zeros_like(poa_global, dtype=float) so internal temperature calculations always use a float dtype.
  • In tests/test_temperature.py:

    • Added test_fuentes_int_float_consistency, which calls fuentes with both integer and float poa_global series (same values, datetime index) and asserts that the results match within floating-point tolerance.

Rationale

Previously, when poa_global was an integer Series, tmod_array was also integer, so intermediate temperatures such as 321.19 K were truncated to 321 when stored. Converting to Celsius (tmod_array - 273.15) produced a different value than for float inputs.

This change ensures that physically identical inputs (100 vs 100.0) produce identical Fuentes outputs.

Testing

  • pytest tests/test_temperature.py::test_fuentes -v
  • pytest tests/test_temperature.py::test_fuentes_int_float_consistency -v

@cwhanse
Copy link
Member

cwhanse commented Dec 10, 2025

@kumaradityaapril please address the formatting issues identified by Flake8.

There are two tests that use the fuentes model that now fail, almost certainly because the expected values were computed with the fuentes function that was doing integer truncation. I think it's OK to update the expected values and use as many digits as needed to get the tests to pass with the default rtol and atol values, so we don't have to relax those tolerances.

@kumaradityaapril
Copy link
Author

Thanks for the review. I’ll address the Flake8 formatting issues and update the Fuentes-related tests.

For the tests that use the Fuentes model, I’ll recompute the expected values using the corrected fuentes implementation and update the hard-coded expectations (with sufficient precision) so that they pass with the default rtol and atol settings, without relaxing tolerances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer/float bug in pvlib.temperature.fuentes

2 participants