Graph#

class psynet.trial.graph.GraphChainNetwork(*args, **kwargs)[source]#

Bases: ChainNetwork

A Network class for graph chains. A graph chain corresponds to the evolution of a vertex within a graph.

Parameters (for now stating the new ones)#

vertex_id

The id of the vertex that the network is representing within the graph.

dependent_vertex_ids

A list of the vertex ids on which the current node depends (incoming edges).

source_seed

Source seed to use when initializing the graph in the trialmaker.

creation_time#

the time at which the Network was created.

details#

a generic column for storing structured JSON data

failed#

boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.

failed_reason#

an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.

full#

Whether the network is currently full

id#

a unique number for every entry. 1, 2, 3 and so on…

max_size#

How big the network can get, this number is used by the full() method to decide whether the network is full

property1#

a generic column that can be used to store experiment-specific details in String form.

property2#

a generic column that can be used to store experiment-specific details in String form.

property3#

a generic column that can be used to store experiment-specific details in String form.

property4#

a generic column that can be used to store experiment-specific details in String form.

property5#

a generic column that can be used to store experiment-specific details in String form.

role#

The role of the network. By default dallinger initializes all networks as either “practice” or “experiment”

time_of_death#

the time at which failing occurred

type#

A String giving the name of the class. Defaults to “network”. This allows subclassing.

vars#
class psynet.trial.graph.GraphChainNode(*args, **kwargs)[source]#

Bases: ChainNode

A Node class for graph chains.

Parameters (for now stating the new ones)#

vertex_id

The id of the vertex that the network is representing within the graph.

dependent_vertex_ids

A list of the vertex ids on which the current node depends (incoming edges).

create_definition_from_seed(seed, experiment, participant)[source]#

(Built-in) In a graph chain, the next node in the chain is a faithful reproduction of the previous iteration.

Parameters:
  • seed – The seed being passed to the node.

  • experiment – An instantiation of psynet.experiment.Experiment, corresponding to the current experiment.

  • participant – Current participant, if relevant.

Returns:

  • object – The node’s new definition, which is a faithful reproduction of the seed that it was passed.

creation_time#

the time at which the Network was created.

details#

a generic column for storing structured JSON data

failed#

boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.

failed_reason#

an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.

id#

a unique number for every entry. 1, 2, 3 and so on…

network#

the network the node is in

network_id#

the id of the network that this node is a part of

participant#

the participant the node is associated with

participant_id#

the id of the participant whose node this is

property1#

a generic column that can be used to store experiment-specific details in String form.

property2#

a generic column that can be used to store experiment-specific details in String form.

property3#

a generic column that can be used to store experiment-specific details in String form.

property4#

a generic column that can be used to store experiment-specific details in String form.

property5#

a generic column that can be used to store experiment-specific details in String form.

summarize_trials(trials, experiment, participant)[source]#

(Abstract method, to be overridden) This method should summarize the answers to the provided trials. A default method is implemented for cases when there is just one trial per node; in this case, the method extracts and returns the trial’s answer, available in trial.answer. The method must be extended if it is to cope with multiple trials per node, however.

Parameters:
  • trials (list) – Trials to be summarized. By default only trials that are completed (i.e. have received a response) and processed (i.e. aren’t waiting for an asynchronous process) are provided here.

  • experiment – An instantiation of psynet.experiment.Experiment, corresponding to the current experiment.

  • participant – The participant who initiated the creation of the node.

Returns:

  • object – The derived seed. Should be suitable for serialisation to JSON.

time_of_death#

the time at which failing occurred

type#

A String giving the name of the class. Defaults to node. This allows subclassing.

vars#
class psynet.trial.graph.GraphChainTrial(*args, **kwargs)[source]#

Bases: ChainTrial

A Trial class for graph chains.

complete#

whether the info is ‘complete’, i.e. has received its contents

creation_time#

the time at which the Network was created.

details#

a generic column for storing structured JSON data

failed#

boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.

failed_reason#

an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.

id#

a unique number for every entry. 1, 2, 3 and so on…

make_definition(experiment, participant)[source]#

(Built-in) In an graph chain, the trial’s definition equals the definition of the node that created it.

Parameters:
  • experiment – An instantiation of psynet.experiment.Experiment, corresponding to the current experiment.

  • participant – Optional participant with which to associate the trial.

Returns:

  • object – The trial’s definition, equal to the node’s definition.

network#

the network the info is in

network_id#

the id of the network the info is in

origin#

the Node that created the info.

origin_id#

the id of the Node that created the info

property1#

a generic column that can be used to store experiment-specific details in String form.

property2#

a generic column that can be used to store experiment-specific details in String form.

property3#

a generic column that can be used to store experiment-specific details in String form.

property4#

a generic column that can be used to store experiment-specific details in String form.

property5#

a generic column that can be used to store experiment-specific details in String form.

time_of_death#

the time at which failing occurred

type#

a String giving the name of the class. Defaults to “info”. This allows subclassing.

vars#
class psynet.trial.graph.GraphChainTrialMaker(*, id_, node_class, trial_class, network_structure, chain_type, expected_trials_per_participant, max_trials_per_participant, chains_per_participant, trials_per_node, balance_across_chains, check_performance_at_end, check_performance_every_trial, recruit_mode, target_n_participants=typing.Optional[int], max_nodes_per_chain=None, fail_trials_on_premature_exit=False, fail_trials_on_participant_performance_check=False, propagate_failure=True, n_repeat_trials=0, wait_for_networks=False, allow_revisiting_networks_in_across_chains=False, sync_group_type=None)[source]#

Bases: ChainTrialMaker

A TrialMaker class for graph chains; see the documentation for ChainTrialMaker for usage instructions.

Parameters:

network_structure – A representation of the graph structure to instantiate. The representation consistes of a dictionary of vertices and edges. E.g. {“vertices”: [1,2], “edges”: [{“origin”: 1, “target”: 2, “properties”: {“type”: “default”}}]}

grow_network(network, experiment)[source]#

Extends the network if necessary by adding one or more nodes. Returns True if any nodes were added.

Parameters:
  • network – The network to be potentially extended.

  • experiment – An instantiation of psynet.experiment.Experiment, corresponding to the current experiment.

pre_deploy_routine(experiment)[source]#

Defines a routine for setting up the experiment prior to deployment. This is a good place to prepare networks etc.

Parameters:

experiment – An instantiation of psynet.experiment.Experiment, corresponding to the current experiment.