How to use the dallinger.experiment.Experiment function in dallinger

To help you get started, we’ve selected a few dallinger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dallinger / Dallinger / tests / test_api.py View on Github external
def test_uuid_instance(self):
        from dallinger.experiment import Experiment

        exp = Experiment()
        exp_uuid = exp.make_uuid()
        assert isinstance(UUID(exp_uuid, version=4), UUID)
github Dallinger / Dallinger / tests / test_experiment.py View on Github external
def klass(self):
        from dallinger.experiment import Experiment

        return Experiment
github Dallinger / Dallinger / tests / test_jupyter.py View on Github external
def exp(self):
        from dallinger.experiment import Experiment

        return Experiment()
github Dallinger / Dallinger / dallinger / command_line.py View on Github external
def uuid():
    """Print a new UUID"""
    from dallinger.experiment import Experiment
    click.echo(Experiment.make_uuid())
github Dallinger / Dallinger / demos / dlgr / demos / concentration / experiment.py View on Github external
"""The game Concentration."""

from dallinger.config import get_config
from dallinger.experiment import Experiment
from dallinger.networks import Empty


def extra_parameters():
    config = get_config()
    config.register("num_participants", int)


class ConcentrationGame(Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Initialize the experiment."""
        super(ConcentrationGame, self).__init__(session)
        self.experiment_repeats = 1
        if session:
            self.setup()

    def configure(self):
        config = get_config()
        self.initial_recruitment_size = config["num_participants"]

    def create_network(self):
        """Return a new network."""
        return Empty(max_size=self.initial_recruitment_size)
github Dallinger / Dallinger / demos / dlgr / demos / chatroom / experiment.py View on Github external
Bot = Bot  # Make name "Bot" importable without triggering style warnings
except ImportError:
    pass

logger = logging.getLogger(__file__)


def extra_parameters():
    config = get_config()
    config.register("network", unicode)
    config.register("repeats", int)
    config.register("n", int)


class CoordinationChatroom(Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Initialize the experiment."""
        super(CoordinationChatroom, self).__init__(session)
        if session:
            self.setup()

    def configure(self):
        config = get_config()
        self.experiment_repeats = repeats = config.get("repeats")
        self.network_class = config.get("network")
        self.quorum = config.get("n")
        # Recruit for all networks at once
        self.initial_recruitment_size = repeats * self.quorum
github Dallinger / Dallinger / demos / dlgr / demos / mcmcp / experiment.py View on Github external
import time
from operator import attrgetter

from flask import Blueprint, Response
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

from dallinger.bots import BotBase
from dallinger.experiment import Experiment
from dallinger import db
from dallinger.networks import Chain


class MCMCP(Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Call the same function in the super (see experiments.py in dallinger).

        The models module is imported here because it must be imported at
        runtime.

        A few properties are then overwritten.

        Finally, setup() is called.
        """
        super(MCMCP, self).__init__(session)
        from . import models

        self.models = models
github Dallinger / Dallinger / demos / chatroom / experiment.py View on Github external
from dallinger.compat import unicode
from dallinger.config import get_config
from dallinger.experiments import Experiment


config = get_config()
logger = logging.getLogger(__file__)


def extra_parameters():
    config.register('network', unicode)
    config.register('repeats', int)
    config.register('n', int)


class CoordinationChatroom(dlgr.experiment.Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Initialize the experiment."""
        super(CoordinationChatroom, self).__init__(session)
        self.experiment_repeats = repeats = config.get('repeats')
        self.quorum = config.get('n')
        # Recruit for all networks at once
        self.initial_recruitment_size = repeats * self.quorum
        self.config = config
        if not self.config.ready:
            self.config.load()
        if session:
            self.setup()

    def create_network(self):
github Dallinger / Dallinger / demos / dlgr / demos / bartlett1932 / experiment.py View on Github external
from dallinger.bots import BotBase
from dallinger.config import get_config
from dallinger.networks import Chain
from dallinger.experiment import Experiment


logger = logging.getLogger(__file__)


def extra_parameters():
    config = get_config()
    config.register("num_participants", int)


class Bartlett1932(Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Call the same function in the super (see experiments.py in dallinger).

        A few properties are then overwritten.

        Finally, setup() is called.
        """
        super(Bartlett1932, self).__init__(session)
        from . import models  # Import at runtime to avoid SQLAlchemy warnings

        self.models = models
        self.experiment_repeats = 1
        self.initial_recruitment_size = 1
        if session:
github Dallinger / Dallinger / demos / dlgr / demos / iterated_drawing / experiment.py View on Github external
"""Bartlett's trasmission chain experiment from Remembering (1932)."""

from dallinger.networks import Chain
from dallinger.experiment import Experiment


class IteratedDrawing(Experiment):
    """Define the structure of the experiment."""

    def __init__(self, session=None):
        """Call the same function in the super (see experiments.py in dallinger).

        The models module is imported here because it must be imported at
        runtime.

        A few properties are then overwritten.

        Finally, setup() is called.
        """
        super(IteratedDrawing, self).__init__(session)
        from . import models

        self.models = models