@@ -27,7 +27,7 @@ class AbTest(models.Model):
2727 Represents an A/B test that has been set up by the user.
2828
2929 The live page content is used as the control, the revision pointed to in
30- the `.treatment_revision ` field contains the changes that are being tested.
30+ the `.variant_revision ` field contains the changes that are being tested.
3131 """
3232
3333 class Status (models .TextChoices ):
@@ -38,7 +38,7 @@ class Status(models.TextChoices):
3838
3939 # These two sound similar, but there's a difference:
4040 # 'Finished' means that we've reached the sample size and testing has stopped
41- # but the user still needs to decide whether to publish the treatment version
41+ # but the user still needs to decide whether to publish the variant version
4242 # or revert back to the control.
4343 # Once they've decided and that action has taken place, the test status is
4444 # updated to 'Completed'.
@@ -47,18 +47,18 @@ class Status(models.TextChoices):
4747
4848 class Version (models .TextChoices ):
4949 CONTROL = 'control' , __ ('Control' )
50- TREATMENT = 'treatment ' , __ ('Treatment ' )
50+ VARIANT = 'variant ' , __ ('Variant ' )
5151
5252 class CompletionAction (models .TextChoices ):
5353 # See docstring of the .complete() method for descriptions
5454 DO_NOTHING = 'do-nothing' , "Do nothing"
5555 REVERT = 'revert' , "Revert to control"
56- PUBLISH = 'publisn' , "Publish treatment "
56+ PUBLISH = 'publisn' , "Publish variant "
5757
5858 page = models .ForeignKey ('wagtailcore.Page' , on_delete = models .CASCADE , related_name = 'ab_tests' )
5959 name = models .CharField (max_length = 255 )
6060 hypothesis = models .TextField (blank = True )
61- treatment_revision = models .ForeignKey ('wagtailcore.PageRevision' , on_delete = models .CASCADE , related_name = '+' )
61+ variant_revision = models .ForeignKey ('wagtailcore.PageRevision' , on_delete = models .CASCADE , related_name = '+' )
6262 goal_event = models .CharField (max_length = 255 )
6363 goal_page = models .ForeignKey ('wagtailcore.Page' , null = True , blank = True , on_delete = models .SET_NULL , related_name = '+' )
6464 sample_size = models .PositiveIntegerField (validators = [MinValueValidator (1 )])
@@ -150,7 +150,7 @@ def finish(self):
150150 Note that this doesn't 'complete' the test: a finished test means
151151 that testing is no longer happening. The test is not complete until
152152 the user decides on the outcome of the test (keep the control or
153- publish the treatment ). This decision is set using the .complete()
153+ publish the variant ). This decision is set using the .complete()
154154 method.
155155 """
156156 self .status = self .Status .FINISHED
@@ -166,14 +166,14 @@ def complete(self, action, user=None):
166166 Actions can be:
167167 - AbTest.CompletionAction.DO_NOTHING - This just completes
168168 the test but does nothing to the page. The control will
169- remain the published version and the treatment will be
169+ remain the published version and the variant will be
170170 in draft.
171171 - AbTest.CompletionAction.REVERT - This completes the test
172172 and also creates a new revision to revert the content back
173173 to what it was in the control while the test was taking
174174 place.
175175 - AbTest.CompletionAction.PUBLISH - This completes the test
176- and also publishes the treatment revision.
176+ and also publishes the variant revision.
177177 """
178178 self .status = self .Status .COMPLETED
179179 self .save (update_fields = ['status' ])
@@ -186,7 +186,7 @@ def complete(self, action, user=None):
186186 self .page .save_revision (user = user , log_action = 'wagtail.revert' ).publish (user = user )
187187
188188 elif action == AbTest .CompletionAction .PUBLISH :
189- self .treatment_revision .publish (user = user )
189+ self .variant_revision .publish (user = user )
190190
191191 def add_participant (self , version = None ):
192192 """
@@ -195,23 +195,23 @@ def add_participant(self, version=None):
195195 # Get current numbers of participants for each version
196196 stats = self .hourly_logs .aggregate (
197197 control_participants = Sum ('participants' , filter = Q (version = self .Version .CONTROL )),
198- treatment_participants = Sum ('participants' , filter = Q (version = self .Version .TREATMENT )),
198+ variant_participants = Sum ('participants' , filter = Q (version = self .Version .VARIANT )),
199199 )
200200 control_participants = stats ['control_participants' ] or 0
201- treatment_participants = stats ['treatment_participants ' ] or 0
201+ variant_participants = stats ['variant_participants ' ] or 0
202202
203203 # Create an equal number of participants for each version
204204 if version is None :
205- if treatment_participants > control_participants :
205+ if variant_participants > control_participants :
206206 version = self .Version .CONTROL
207207
208- elif treatment_participants < control_participants :
209- version = self .Version .TREATMENT
208+ elif variant_participants < control_participants :
209+ version = self .Version .VARIANT
210210
211211 else :
212212 version = random .choice ([
213213 self .Version .CONTROL ,
214- self .Version .TREATMENT ,
214+ self .Version .VARIANT ,
215215 ])
216216
217217 # Add new participant to statistics model
@@ -222,7 +222,7 @@ def add_participant(self, version=None):
222222 # get a chance to turn into conversions. It's unlikely to make a
223223 # significant difference to the results.
224224 # Note: Adding 1 to account for the new participant
225- if control_participants + treatment_participants + 1 >= self .sample_size :
225+ if control_participants + variant_participants + 1 >= self .sample_size :
226226 self .finish ()
227227
228228 return version
@@ -240,7 +240,7 @@ def check_for_winner(self):
240240 """
241241 Performs a Chi-Squared test to check if there is a clear winner.
242242
243- Returns Version.CONTROL or Version.TREATMENT if there is one. Otherwise, it returns None.
243+ Returns Version.CONTROL or Version.VARIANT if there is one. Otherwise, it returns None.
244244
245245 For more information on what the Chi-Squared test does, see:
246246 https://www.evanmiller.org/ab-testing/chi-squared.html
@@ -250,30 +250,30 @@ def check_for_winner(self):
250250 stats = self .hourly_logs .aggregate (
251251 control_participants = Sum ('participants' , filter = Q (version = self .Version .CONTROL )),
252252 control_conversions = Sum ('conversions' , filter = Q (version = self .Version .CONTROL )),
253- treatment_participants = Sum ('participants' , filter = Q (version = self .Version .TREATMENT )),
254- treatment_conversions = Sum ('conversions' , filter = Q (version = self .Version .TREATMENT )),
253+ variant_participants = Sum ('participants' , filter = Q (version = self .Version .VARIANT )),
254+ variant_conversions = Sum ('conversions' , filter = Q (version = self .Version .VARIANT )),
255255 )
256256 control_participants = stats ['control_participants' ] or 0
257257 control_conversions = stats ['control_conversions' ] or 0
258- treatment_participants = stats ['treatment_participants ' ] or 0
259- treatment_conversions = stats ['treatment_conversions ' ] or 0
258+ variant_participants = stats ['variant_participants ' ] or 0
259+ variant_conversions = stats ['variant_conversions ' ] or 0
260260
261- if not control_conversions and not treatment_conversions :
261+ if not control_conversions and not variant_conversions :
262262 return
263263
264- if control_conversions > control_participants or treatment_conversions > treatment_participants :
264+ if control_conversions > control_participants or variant_conversions > variant_participants :
265265 # Something's up. I'm sure it's already clear in the UI what's going on, so let's not crash
266266 return
267267
268268 # Create a numpy array with values to pass in to Chi-Squared test
269269 control_failures = control_participants - control_conversions
270- treatment_failures = treatment_participants - treatment_conversions
270+ variant_failures = variant_participants - variant_conversions
271271
272- if control_failures == 0 and treatment_failures == 0 :
272+ if control_failures == 0 and variant_failures == 0 :
273273 # Prevent this error: "The internally computed table of expected frequencies has a zero element at (0, 1)."
274274 return
275275
276- T = np .array ([[control_conversions , control_failures ], [treatment_conversions , treatment_failures ]])
276+ T = np .array ([[control_conversions , control_failures ], [variant_conversions , variant_failures ]])
277277
278278 # Perform Chi-Squared test
279279 p = scipy .stats .chi2_contingency (T , correction = False )[1 ]
@@ -283,10 +283,10 @@ def check_for_winner(self):
283283 if 1 - p > required_confidence_level :
284284 # There is a clear winner!
285285 # Return the one with the highest success rate
286- if (control_conversions / control_participants ) > (treatment_conversions / treatment_participants ):
286+ if (control_conversions / control_participants ) > (variant_conversions / variant_participants ):
287287 return self .Version .CONTROL
288288 else :
289- return self .Version .TREATMENT
289+ return self .Version .VARIANT
290290
291291 def get_status_description (self ):
292292 """
@@ -303,8 +303,8 @@ def get_status_description(self):
303303 if self .winning_version == AbTest .Version .CONTROL :
304304 return status + " (" + _ ("Control won" ) + ")"
305305
306- elif self .winning_version == AbTest .Version .TREATMENT :
307- return status + " (" + _ ("Treatment won" ) + ")"
306+ elif self .winning_version == AbTest .Version .VARIANT :
307+ return status + " (" + _ ("Variant won" ) + ")"
308308
309309 else :
310310 return status + " (" + _ ("No clear winner" ) + ")"
0 commit comments