@@ -228,8 +228,11 @@ def test_projected_solar_zenith_angle_datatypes(
228
228
@pytest .fixture
229
229
def sf_premises_and_expected ():
230
230
"""Data comprised of solar position, tracker orientations, ground coverage
231
- ratios and terrain slopes with respective shade fractions (sf)"""
232
- # preserve tracker_shade_fraction's args order and append shadow depth, z
231
+ ratios and terrain slopes with respective shade fractions (sf).
232
+ Returns a 2-tuple with the premises to be used directly in
233
+ tracker_shade_fraction(...) in the first element and the expected shaded
234
+ fractions on the second element"""
235
+ # tracker_shade_fraction's args order and append shadow depth, z
233
236
premises_and_results = pd .DataFrame (
234
237
columns = ["solar_zenith" , "solar_azimuth" , "tracker_tilt" ,
235
238
"tracker_azimuth" , "gcr" , "cross_axis_slope" , "z" ],
@@ -245,14 +248,14 @@ def sf_premises_and_expected():
245
248
))
246
249
# append shaded fraction
247
250
premises_and_results ["shaded_fraction" ] = 1 - 1 / premises_and_results ["z" ]
248
- return premises_and_results
251
+ return (premises_and_results .drop (columns = ["z" , "shaded_fraction" ]),
252
+ premises_and_results ["shaded_fraction" ])
249
253
250
254
251
255
def test_tracker_shade_fraction (sf_premises_and_expected ):
252
256
"""Tests tracker_shade_fraction"""
253
257
# unwrap sf_premises_and_expected values premises and expected results
254
- premises = sf_premises_and_expected .drop (columns = ["z" , "shaded_fraction" ])
255
- expected_sf_array = sf_premises_and_expected ["shaded_fraction" ]
258
+ premises , expected_sf_array = sf_premises_and_expected
256
259
# test scalar inputs from the row iterator
257
260
# series label := corresponding index in expected_sf_array
258
261
for index , premise in premises .iterrows ():
@@ -266,7 +269,7 @@ def test_tracker_shade_fraction(sf_premises_and_expected):
266
269
267
270
268
271
def test_linear_shade_loss (sf_premises_and_expected ):
269
- expected_sf_array = sf_premises_and_expected [ "shaded_fraction" ]
272
+ _ , expected_sf_array = sf_premises_and_expected # Premises are not needed
270
273
loss = shading .linear_shade_loss (expected_sf_array [0 ], 0.2 )
271
274
assert_allclose (loss , 0.09289321881345258 )
272
275
# if no diffuse, shade fraction is the loss
0 commit comments