Experiment#

class alfred3.experiment.Experiment(session_timeout: int = 86400)[source]#

Bases: object

Used to construct the experiment in script.py.

Experiment members can be added with the augmented assigment operator += (see exampples). They can be accessed with the dictionary-style square bracket syntac and with the attribute-style dot syntax (see examples).

The class acts as an organizing container for pages and section for orderly instantiation of the ExperimentSession.

Examples

Create an experiment and add simple page in object oriented style:

import alfred3 as al
exp = al.Experiment()

@exp.member
class HelloWorld(al.Page):

    def on_exp_access(self):
        self += al.TextEntry(toplab="Enter something", name="text1")

Access a page with square bracket syntax.

>>> exp["page1"]
Page(class="Page", name="page1")

Access a page with attribute syntax

>>> exp.page1
Page(class="Page", name="page1")

Methods

abort

Decorator for functions that work on the experiment session directly upon abortion.

append

Append members to the experiment.

as_final_page

Class decorator for adding a custom final page to the experiment.

create_session

Creates an experiment session.

finish

Decorator for code to be run upon ExperimentSession.finish().

member

Decorator for adding pages and sections to the experiment.

run

Runs the experiment.

setup

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

Attributes

admin

final_page

The experiment's final page.

members

A dictionary of all pages and sections added to the experiment.

setup_functions

A list of function that will be called upon creation of an experiment session.

finish_functions

A list of function that will be called upon finishing an experiment session.

abort_functions

A list of function that will be called upon aborting an experiment session.