Skip to content

Commit

Permalink
Improve pytest coverage by removing extraneous try:except KeyError ch…
Browse files Browse the repository at this point in the history
…eck.
  • Loading branch information
cdeline committed Mar 11, 2024
1 parent cea2415 commit 5770393
Showing 1 changed file with 10 additions and 46 deletions.
56 changes: 10 additions & 46 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2320,29 +2320,10 @@ def makeScene1axis(self, trackerdict=None, module=None, sceneDict=None,
# Calculate the ground clearance height based on the hub height. Add abs(theta) to avoid negative tilt angle errors
#trackerdict[theta]['clearance_height'] = height

try:
sceneDict.update({'tilt' : trackerdict[theta]['surf_tilt'],
'clearance_height' : height,
'azimuth' : trackerdict[theta]['surf_azm'],
'modulez' : scene.module.z})

# sceneDict2 = {'tilt':trackerdict[theta]['surf_tilt'],
# 'pitch':sceneDict['pitch'],
# 'clearance_height':height,
# 'azimuth':trackerdict[theta]['surf_azm'],
# 'nMods': sceneDict['nMods'],
# 'nRows': sceneDict['nRows'],
# 'modulez': scene.module.z}
except KeyError as err:
#maybe gcr is passed, not pitch
# sceneDict2 = {'tilt':trackerdict[theta]['surf_tilt'],
# 'gcr':sceneDict['gcr'],
# 'clearance_height':height,
# 'azimuth':trackerdict[theta]['surf_azm'],
# 'nMods': sceneDict['nMods'],
# 'nRows': sceneDict['nRows'],
# 'modulez': scene.module.z}
raise err
sceneDict.update({'tilt' : trackerdict[theta]['surf_tilt'],
'clearance_height' : height,
'azimuth' : trackerdict[theta]['surf_azm'],
'modulez' : scene.module.z})

radfile = scene._makeSceneNxR(sceneDict=(sceneDict),
radname=radname)
Expand Down Expand Up @@ -2370,29 +2351,12 @@ def makeScene1axis(self, trackerdict=None, module=None, sceneDict=None,

if trackerdict[time]['ghi'] > 0:
#trackerdict[time]['clearance_height'] = height
try:
sceneDict.update({'tilt' : trackerdict[time]['surf_tilt'],
'clearance_height' : height,
'azimuth' : trackerdict[time]['surf_azm'],
'modulez' : scene.module.z})
# sceneDict2 = {'tilt':trackerdict[time]['surf_tilt'],
# 'pitch':sceneDict['pitch'],
# 'clearance_height': height,
# 'azimuth':trackerdict[time]['surf_azm'],
# 'nMods': sceneDict['nMods'],
# 'nRows': sceneDict['nRows'],
# 'modulez': scene.module.z}

except KeyError as err:
#maybe gcr is passed instead of pitch
# sceneDict2 = {'tilt':trackerdict[time]['surf_tilt'],
# 'gcr':sceneDict['gcr'],
# 'clearance_height': height,
# 'azimuth':trackerdict[time]['surf_azm'],
# 'nMods': sceneDict['nMods'],
# 'nRows': sceneDict['nRows'],
# 'modulez': scene.module.z}
raise err

sceneDict.update({'tilt' : trackerdict[time]['surf_tilt'],
'clearance_height' : height,
'azimuth' : trackerdict[time]['surf_azm'],
'modulez' : scene.module.z})

# if sceneDict isn't copied, it will change inside the SceneObj since dicts are mutable!
radfile = scene._makeSceneNxR(sceneDict=(sceneDict),
radname=radname)
Expand Down

0 comments on commit 5770393

Please sign in to comment.