psi.core package
Subpackages
Submodules
psi.core.api module
psi.core.app_id module
Taskbar identity for psi programs.
Deliberately free of enaml, atom and Qt imports so that a program can call set_app_id from the very top of its main, before the GUI machinery is loaded.
- psi.core.app_id.set_app_id(app_id)[source]
Give this process its own identity on the Windows taskbar.
Windows groups taskbar buttons by AppUserModelID, and a Python GUI that never sets one inherits the interpreter’s. Without this every psi program shares a single taskbar button showing Python’s icon (or the console-script wrapper’s), no matter what icon its windows carry.
psivideo keeps its own copy of this (it does not depend on psi). Keep the two in sync.
- Parameters:
app_id (string) – Dotted identifier, by convention psi.<program> (e.g., psi.cftscal, psi.noise-exp). psi itself claims psi.psi, leaving the launchers that spawn it free to claim their own so that a launcher and its experiments get separate taskbar buttons.
Notes
Call this from the program’s entry point before the Qt application is created. Once a window exists Windows has already bound the process to the default ID and this has no effect.
No-op off Windows, and fails soft: a mis-grouped taskbar button is cosmetic and shouldn’t keep the program from starting.
psi.core.console module
Console setup for psi’s command-line entry points.
Deliberately free of enaml, atom and Qt imports, so that a command which
needs no GUI (psi-config) does not load it just to configure the
console.
psi.core.exceptions module
Exception hierarchy for psiexperiment.
Catching PSIException distinguishes errors raised (and understood)
by the framework from arbitrary programming errors.
- exception psi.core.exceptions.ActionError(message, action=None, event=None)[source]
Bases:
PSIExceptionRaised when an ExperimentAction’s command or callback fails.
The original exception is available as
__cause__.- action
The ExperimentActionBase instance that failed.
- event
Name of the event that triggered the action.
psi.core.experiment_action module
- class psi.core.experiment_action.EventLogger(parent=None, **kwargs)[source]
Bases:
DeclarativeDefines a command that is invoked whenever an event occurs
- command
A value of type str.
By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.
- class psi.core.experiment_action.ExperimentAction(parent=None, **kwargs)[source]
Bases:
ExperimentActionBase- command
Command to invoke
- class psi.core.experiment_action.ExperimentActionBase(parent=None, **kwargs)[source]
Bases:
Declarative- allow_unregistered
If True, the controller’s startup validation will not require the names referenced by event to be registered events or state flags. Only set this for events that are generated dynamically at runtime.
- delay
Should action be delayed? If nonzero, this may cause some timing issues. Use with caution.
- dependencies
A member which allows list values.
Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.
- event
A value of type str.
By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.
- invocations
Number of times the command was invoked
- kwargs
Arguments to pass to command by keyword
- match
A value which is callable.
- weight
Defines order of invocation. Less than 100 invokes before default. Higher than 100 invokes after default. Note that if concurrent is True, then order of execution is not guaranteed.
- class psi.core.experiment_action.ExperimentCallback(parent=None, **kwargs)[source]
Bases:
ExperimentActionBase- callback
Callback to invoke
- class psi.core.experiment_action.ExperimentEvent(parent=None, **kwargs)[source]
Bases:
Declarative- associated_state
A value which allows objects of a given type or types.
Values will be tested using the PyObject_TypeCheck C API call. This call is equivalent to type(obj) in cls.mro(). It is less flexible but can be faster than Instance. Use Instance when allowing you need a tuple of types or (abstract) types relying on custom __isinstancecheck__ and Typed when the value type is explicit.
If optional is True, the value of a Typed may be set to None, otherwise None is not considered as a valid value.
- name
Export the ‘name’ attribute as a declarative member.
- class psi.core.experiment_action.ExperimentState(parent=None, **kwargs)[source]
Bases:
DeclarativeAllows for indication of a state (e.g., experiment_active, iti_active). Automatically contributes the start/end events associataed with the state (e.g., experiment_start, experiment_end).
- events = ['prepare', 'start', 'end']
- name
Export the ‘name’ attribute as a declarative member.
psi.core.metadata_item module
psi.core.preferences module
- class psi.core.preferences.ItemPreferences(parent=None, **kwargs)[source]
Bases:
_AutoPreferences- item
A member class which supports value initialization.
A plain Value provides support for default values and factories, but does not perform any type checking or validation. It serves as a useful base class for scalar members and can be used for cases where type checking is not needed (like private attributes).