Update phase/compute.py
Browse filesadded input validation for 'participants_by_group'
- phase/compute.py +3 -0
phase/compute.py
CHANGED
|
@@ -26,6 +26,9 @@ class ParticipationAdoptionIndex:
|
|
| 26 |
|
| 27 |
# ---------- public API ----------
|
| 28 |
def compute_pai(self, participants_by_group=None):
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# absolute counts
|
| 31 |
spi_a_abs = self.target_population - self.num_participants
|
|
|
|
| 26 |
|
| 27 |
# ---------- public API ----------
|
| 28 |
def compute_pai(self, participants_by_group=None):
|
| 29 |
+
|
| 30 |
+
# input validation for 'participants_by_group'
|
| 31 |
+
self.num_participants = sum(participants_by_group.values()) if participants_by_group else num_participants
|
| 32 |
|
| 33 |
# absolute counts
|
| 34 |
spi_a_abs = self.target_population - self.num_participants
|