diff --git a/docs/sphinx/source/whatsnew/v0.15.1.rst b/docs/sphinx/source/whatsnew/v0.15.1.rst index 5cd4131c85..ea278d3e9c 100644 --- a/docs/sphinx/source/whatsnew/v0.15.1.rst +++ b/docs/sphinx/source/whatsnew/v0.15.1.rst @@ -28,7 +28,9 @@ Documentation Testing ~~~~~~~ - +* Add test to verify that :py:func:`~pvlib.transformer.simple_efficiency` + produces consistent results for vectorized and scalar inputs. + (:pull:`2661`) Benchmarking ~~~~~~~~~~~~ diff --git a/tests/test_transformer.py b/tests/test_transformer.py index 48f11e0a45..1c65487284 100644 --- a/tests/test_transformer.py +++ b/tests/test_transformer.py @@ -5,6 +5,8 @@ from pvlib import transformer +import numpy as np + def test_simple_efficiency(): @@ -61,6 +63,27 @@ def test_simple_efficiency_known_values(): ) +def test_simple_efficiency_vector_equals_scalar(): + input_power = np.array([200.0, 600.0, 900.0]) + no_load_loss = 0.005 + load_loss = 0.01 + rating = 1000.0 + + vector_result = transformer.simple_efficiency( + input_power=input_power, + no_load_loss=no_load_loss, + load_loss=load_loss, + transformer_rating=rating + ) + + scalar_result = np.array([ + transformer.simple_efficiency(p, no_load_loss, load_loss, rating) + for p in input_power + ]) + + assert_allclose(vector_result, scalar_result) + + @pytest.mark.parametrize( "input_power, no_load_loss, load_loss, transformer_rating, expected", [