Skip to content

Commit

Permalink
Merge pull request #559 from NCATSTranslator/celery_test
Browse files Browse the repository at this point in the history
added a check for null scores in result's analyses
  • Loading branch information
ShervinAbd92 authored Jan 10, 2024
2 parents 696bd1f + 88a2425 commit a4e594d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,12 +1270,21 @@ def normalizeScores(results):
temp_score = []
for analysis in res['analyses']:
if 'score' in analysis.keys():
temp_score.append(analysis['score'])
if analysis['score'] is not None:
temp_score.append(analysis['score'])
else:
logging.error("Analyses score field is null, setting it to zero")
analysis['score']=0
temp_score.append(analysis['score'])

score = statistics.mean(temp_score)

elif len(res['analyses']) == 1:
if 'score' in res['analyses'][0]:
score = res['analyses'][0]['score']
if res['analyses'][0]['score'] is not None:
score = res['analyses'][0]['score']
else:
score = 0
else:
logging.debug('Result doesnt have score field')
score = None
Expand Down

0 comments on commit a4e594d

Please sign in to comment.