Skip to content

Commit e7fc536

Browse files
Merge pull request #492 from OpenSPP/pmt-weight-fix
Fixed division by zero error
2 parents a966611 + d616e93 commit e7fc536

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spp_pmt/models/pmt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def compute_score(self, field_name):
7676
if hasattr(ind.individual, field):
7777
total_score += getattr(ind.individual, field) * weight
7878
total_weight += weight
79-
z_ind_grp_pmt_score = total_score / total_weight
79+
if total_weight > 0:
80+
z_ind_grp_pmt_score = total_score / total_weight
81+
else:
82+
z_ind_grp_pmt_score = 0
8083
setattr(record, field_name, z_ind_grp_pmt_score)
8184
else:
8285
setattr(record, field_name, 0)

0 commit comments

Comments
 (0)