Fixed division by 0 error in calc_imputations
This commit is contained in:
parent
58c4aa2a97
commit
3c0e8af223
2 changed files with 13 additions and 3 deletions
|
|
@ -114,13 +114,13 @@ class Teacher(models.Model):
|
|||
for key in imputations:
|
||||
imputations[key] += round(imputations[key] / tot * activities['tot_formation'])
|
||||
|
||||
# Split EDE périods in EDEpe and EDEps columns, in proportion
|
||||
# Split EDE periods in EDEpe and EDEps columns, in proportion
|
||||
ede = courses.filter(imputation='EDE').aggregate(models.Sum('period'))['period__sum'] or 0
|
||||
if ede > 0:
|
||||
pe = imputations['EDEpe']
|
||||
ps = imputations['EDEps']
|
||||
pe_percent = pe / (pe + ps)
|
||||
pe_plus = pe * pe_percent
|
||||
pe_percent = (pe / (pe + ps)) if (pe + ps) > 0 else 0.5
|
||||
pe_plus = round(ede * pe_percent)
|
||||
imputations['EDEpe'] += pe_plus
|
||||
imputations['EDEps'] += ede - pe_plus
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue