Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.15.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(:pull:`2661`)
(:issue:`2649`, :pull:`2661`)


Benchmarking
~~~~~~~~~~~~
Expand Down
23 changes: 23 additions & 0 deletions tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from pvlib import transformer

import numpy as np


def test_simple_efficiency():

Expand Down Expand Up @@ -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",
[
Expand Down