|
1 | 1 | import pandas as pd |
| 2 | +import numpy as np |
| 3 | +import pytest |
2 | 4 |
|
3 | 5 | from numpy.testing import assert_allclose |
4 | | - |
| 6 | +from pvlib.transformer import simple_efficiency |
5 | 7 | from pvlib import transformer |
6 | 8 |
|
7 | 9 |
|
@@ -48,13 +50,47 @@ def test_simple_efficiency_known_values(): |
48 | 50 |
|
49 | 51 | # verify correct behavior at no-load condition |
50 | 52 | assert_allclose( |
51 | | - transformer.simple_efficiency(no_load_loss*rating, *args), |
| 53 | + transformer.simple_efficiency(no_load_loss * rating, *args), |
52 | 54 | 0.0 |
53 | 55 | ) |
54 | 56 |
|
55 | 57 | # verify correct behavior at rated condition |
56 | 58 | assert_allclose( |
57 | | - transformer.simple_efficiency(rating*(1 + no_load_loss + load_loss), |
58 | | - *args), |
| 59 | + transformer.simple_efficiency( |
| 60 | + rating * (1 + no_load_loss + load_loss), |
| 61 | + *args |
| 62 | + ), |
59 | 63 | rating, |
60 | 64 | ) |
| 65 | + |
| 66 | + |
| 67 | +# ========================= |
| 68 | +# NEW TESTS (Issue #2649) |
| 69 | +# ========================= |
| 70 | + |
| 71 | +def test_simple_efficiency_numpy_input_power(): |
| 72 | + input_power = np.array([500, 1000, 1500]) |
| 73 | + no_load_loss = 0.01 |
| 74 | + load_loss = 0.02 |
| 75 | + transformer_rating = 2000 |
| 76 | + |
| 77 | + output = simple_efficiency( |
| 78 | + input_power, no_load_loss, load_loss, transformer_rating |
| 79 | + ) |
| 80 | + |
| 81 | + assert isinstance(output, np.ndarray) |
| 82 | + assert output.shape == input_power.shape |
| 83 | + |
| 84 | + |
| 85 | +def test_simple_efficiency_zero_load_loss(): |
| 86 | + input_power = np.array([500, 1000]) |
| 87 | + no_load_loss = 0.01 |
| 88 | + load_loss = 0.0 |
| 89 | + transformer_rating = 2000 |
| 90 | + |
| 91 | + with pytest.warns(RuntimeWarning): |
| 92 | + output = simple_efficiency( |
| 93 | + input_power, no_load_loss, load_loss, transformer_rating |
| 94 | + ) |
| 95 | + |
| 96 | + assert np.all(np.isnan(output)) |
0 commit comments