• Github
Table of Contents
0.16.1.0
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • Preferences
Shortcuts

Preferences¶

Preferences specify the behavior of Components when they are executed. They can be specified by their value, or by a PreferenceSet, which specifies the

Standard Preferences¶

The following preferences are available for all Components (see Component prefs for additional details):

  • verbosePref (bool : default False) - enables/disables reporting of (non-exception) warnings and system function;

  • paramValidationPref (bool : default False) - enables/disables run-time validation of the execute method of a Function object;

  • reportOutputPref (ReportOutput or list[ReportOutput, PARAMS or str, str…] : default ReportOutput.OFF) - enables/disables and determines format and content for reporting execution of the Component (see ReportOutput for options). The following options can be used (also see Examples below):

    • ReportOutput.OFF - suppress reporting execution of the Component;

    • ReportOutput.TERSE - report only the execution of the Component, but no information about it;

    • ReportOutput.FULL - report the input and output of the Component when it is executed;

    • [ReportOutput.FULL, PARAMS] - report the input and output as well as the value of all of the Component’s

    Parameters when it is executed;

    • [ReportOutput.FULL, <parameter name>, <parameter name>…] - report the value of specific Parameters of

      the Component and/or its function. Specifying VARIABLE and/or VALUE displays the variable and/or value attributes of a Mechanism, respectivey, and not those attributes of its primary function or secondary ones.

    Note

    The reportOutputPref settings for a Component only take effect when the Component is executed on it own (using its execute method) or if ReportOutput.USE_PREFS is specified in the report_output argument of one of the Composition’s execution methods. Otherwise, the ReportOutput option specified in the report_output and report_params arguments of a Composition’s execution method takes precedence (see ReportOutput).

  • logPref (LogCondition : default LogCondition.OFF) - sets LogCondition for a given Component;

  • deliverPref (LogCondition, default: LogCondition.OFF) - sets whether attribute data are added to context rpc pipeline for delivery to external applications.

Examples

reportOutputPref¶

By default, executing a Component, such as the Mechanism below, does not produce any output:

>>> import psyneulink as pnl
>>> my_mech = pnl.TransferMechanism()
>>> my_mech.execute()

Output can be specified by specifying a value of ReportOutput as the Mechanism’s reportOutputPref preference. Assigning ReportOutput.FULL generates a report of its input and output values when it was executed:

>>> my_mech.reportOutputPref = pnl.ReportOutput.FULL
>>> my_mech.execute()
╭─ My Mechanism ─╮
│ input: 0.0     │
│ output: 0.0    │
╰────────────────╯

Assigning ReportOutput.TERSE generates a simpler report:

>>> my_mech.reportOutputPref = pnl.ReportOutput.TERSE
>>> my_mech.execute()
 My Mechanism executed

This can be useful when there are many Components executed (e.g., as part of the execution of a complex Composition.

Assigning the PARAMS keyword with ReportOutput.FULL produces a display of the Mechanism’s input and output as well as the value of all of its Parameters (for brevity, not all are shown below):

>>> my_mech.reportOutputPref = [ReportOutput.FULL, pnl.PARAMS]
>>> my_mech.execute()
╭────────────────────────────────────────── My Mechanism ──────────────────────────────────────────╮
│ input: 0.0                                                                                       │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ params:                                                                                      │ │
   ...
│ │         integration_rate: 0.5                                                                │ │
   ...
│ │         noise: 0.0                                                                           │ │
   ...
│ │         function: Linear Function-6                                                          │ │
│ │                 intercept: 0.0                                                               │ │
   ...
│ │                 slope: 1.0                                                                   │ │
│ │                 value: 0.0                                                                   │ │
│ │                 variable: 0.0                                                                │ │
│ │         integrator_function: AdaptiveIntegrator Function-1                                   │ │
   ...
│ │                 previous_value: 0                                                            │ │
│ │                 rate: 0.5                                                                    │ │
│ │                 value: 0.0                                                                   │ │
│ │                 variable: 0                                                                  │ │
│ │         termination_measure: Distance Function-5                                             │ │
   ...
│ │                 metric: max_abs_diff                                                         │ │
│ │                 normalize: False                                                             │ │
│ │                 value: 0.0                                                                   │ │
│ │                 variable: 0 0                                                                │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ output: 0.0                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Note that specifying PARAMS forces a full output (i.e., equivalent to also specifying ReportOutput.FULL).

Generally, not all of a Component’s Parameters are of interest. The display can be restricted to just those of interest by including them in a list specified for reportOutputPref:

>>> my_mech.reportOutputPref = [ReportOutout.FULL, 'integration_rate', 'slope', 'rate']
>>> my_mech.execute()
╭────────────────────────────────────────── My Mechanism ──────────────────────────────────────────╮
│ input: 0.0                                                                                       │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ params:                                                                                      │ │
│ │         integration_rate: 0.5                                                                │ │
│ │         function: Linear Function-6                                                          │ │
│ │                 slope: 1.0                                                                   │ │
│ │         integrator_function: AdaptiveIntegrator Function-1                                   │ │
│ │                 rate: 0.5                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ output: 0.0                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Note that this is overridden if ReportOutput.TERSE is specified:

>>> my_mech.reportOutputPref = [pnl.ReportOutput.TERSE, 'integration_rate', 'slope', 'rate']
>>> my_mech.execute()
 My Mechanism executed

When a Mechanism is executed as part of a Composition, the Composition’s reportOutputPref takes precedence:

>>> my_mech.reportOutputPref = ['integration_rate', 'slope', 'rate']
>>> my_comp = pnl.Composition(pathways=[my_mech])
>>> my_comp.run()

Note that the Composition’s setting, which is ReportOutput.OFF by default, overrode the Mechanism’s reportOutputPref settings. The report_output argument of a Composition’s execution method can also be used to specify report contents; this too overrides the Mechanism’s reportOutputPref setting:

>>> my_mech.reportOutputPref = ['integration_rate', 'slope', 'rate', pnl.ReportOutput.FULL]
>>> my_comp.run(report_output=pnl.ReportOutput.TERSE)
Composition-0 TRIAL 0 ====================
 Time Step 0 ---------
   My Mechanism executed

ReportOutput.USE_PREFS can be used in the report_output argument to allow the reportOutputPref of individual Components to determine what is displayed when a Composition is executed. See ReportOutput for other options and additional examples of how to report_output argument of a Composition’s execution methods can be used to configure the output.


© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • Preferences
    • Standard Preferences
      • reportOutputPref
  • Github