Skip to content

Commit

Permalink
Update test_spectrum.py
Browse files Browse the repository at this point in the history
fix indentation and white spaces, change clearness to clearsky
  • Loading branch information
RDaxini committed Jun 7, 2024
1 parent 639fc75 commit 7c50791
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions pvlib/tests/test_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def test_spectral_factor_caballero_supplied_ambiguous():
spectrum.spectral_factor_caballero(1, 1, 1, module_type=None,
coefficients=None)


@pytest.mark.parametrize("module_type,expected", [
('asi', np.array([1.15534029, 1.1123772, 1.08286684])),
('fs-2', np.array([1.0694323, 1.04948777, 1.03556288])),
Expand All @@ -328,43 +329,50 @@ def test_spectral_factor_pelland(module_type, expected):
ams = np.array([1.0, 1.5, 2.0])
kcs = np.array([0.4, 0.6, 0.8])
out = spectrum.spectral_factor_pelland(ams, kcs,
module_type=module_type)
module_type=module_type)
assert np.allclose(expected, out, atol=1e-3)


def test_spectral_factor_pelland_supplied():
# use the multisi coeffs
coeffs = (
0.9847, -0.05237, 0.03034)
out = spectrum.spectral_factor_pelland(1.5, 0.8, coefficients=coeffs)
expected = 1.00860641
assert_allclose(out, expected, atol=1e-3)



def test_spectral_factor_pelland_supplied_redundant():
# Error when specifying both module_type and coefficients
coeffs = (
0.9847, -0.05237, 0.03034)
with pytest.raises(ValueError):
spectrum.spectral_factor_pelland(1.5, 0.8, module_type='multisi',
coefficients=coeffs)
coefficients=coeffs)


def test_spectral_factor_pelland_supplied_ambiguous():
# Error when specifying neither module_type nor coefficients
with pytest.raises(ValueError):
spectrum.spectral_factor_pelland(1.5, 0.8, module_type=None,
coefficients=None)

coefficients=None)


def test_spectral_factor_pelland_low_airmass():
with pytest.warns(UserWarning, match='Exceptionally low air mass'):
_ = spectrum.spectral_factor_pelland(0.1, 0.8, 'multisi')
_ = spectrum.spectral_factor_pelland(0.1, 0.8, 'multisi')


def test_spectral_factor_pelland_high_airmass():
with pytest.warns(UserWarning, match='Exceptionally high air mass'):
_ = spectrum.spectral_factor_pelland(12, 0.8, 'multisi')

def test_spectral_factor_pelland_low_clearnessindex():
with pytest.raises(ValueError, match='Clearness index cannot be negative'):
_ = spectrum.spectral_factor_pelland(1.5, -0.8, 'multisi')

def test_spectral_factor_pelland_high_clearnessindex():
with pytest.raises(ValueError, match='Clearness index cannot be >1'):

def test_spectral_factor_pelland_low_clearskyindex():
with pytest.raises(ValueError, match='Clearsky index cannot be negative'):
_ = spectrum.spectral_factor_pelland(1.5, -0.8, 'multisi')


def test_spectral_factor_pelland_high_clearskysindex():
with pytest.raises(ValueError, match='Clearsky index cannot be >1'):
_ = spectrum.spectral_factor_pelland(1.5, 1.8, 'multisi')

0 comments on commit 7c50791

Please sign in to comment.