ExperimentAdmin.setup()#

ExperimentAdmin.setup(func)[source]#

Decorator for functions that work on the experiment session directly after intialization.

The decorated function can have an arbitrary name. It must take an ExperimentSession object as its only argument (usually spelled as exp). You can use this decorator on as many function as you like.

The purpose of this decorator is to allow manipulation of the ExperimentSession object generated by Experiment.

See also

This decorator basically works the same as abort() and finish(), just at a different time.

Examples

In this example, we use the the @exp.setup decorator to add a plugin to the experiment session’s plugin dictionary and access that same plugin later in a page hook:

import alfred3 as al
exp = al.Experiment()

@exp.setup
def setup(exp):
    exp.plugins["a"] = "mock plugin"

@exp.member
class HelloWorld(al.Page):
    name = "hello_world"

    def on_exp_access(self):
        print(self.exp.plugins["a"])