stytra
stytra copied to clipboard
Clean-up Experiment dependencies inside Stimulus
With this PR the protocol runner passes the calibrator object from the method initialise_external()
.
To avoid problems with existing custom stimuli which may have rewritten the method I added two warnings.
More specifically I expect two cases to throw errors:
- if the protocol runner calls a custom stimulus where the
initialise_external()
function doesn't accept thecalibrator
input. - if the function
initialise_external()
is used without passing thecalibrator
input.
To fix 1:
in the protocol runner there's a try{} except{}
block that tries to feed the calibrator object to the stimulus initialise_external() function. If this doesn't work then the protocol runner raises a warning and then calls the function without the calibrator
input.
To fix 2:
the initialise_external()
has an optional argument calibrator
which has default value -999, if the default value is detected then the self._calibrator
is initialized with the self._experiment
and a warning is given to the user.
else the self._calibrator
is initialized with the calibrator
input
Finally:
In all the others default stimuli the _calibrator
object is used instead of _experiment.calibrator