Open fedem-p opened 2 years ago
Update: I have created a Dataclass called EnvironmentState which olds different attributes:
The last two are still unused.
The way it works is the same as before:
the protocol runner passes an _environment_state
instance to the stimulus through the initialise_external
method.
Here it gets initialized as a stimulus variable (if the input is not an instance of the EnvironmentState class the variable is initialized as a copy of the experiment object)
in the rest of the stimulus files the calls to calibrator and estimator go through the _environment_state
variable
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:
initialise_external()
function doesn't accept thecalibrator
input.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 thecalibrator
input.To fix 2:
the
initialise_external()
has an optional argumentcalibrator
which has default value -999, if the default value is detected then theself._calibrator
is initialized with theself._experiment
and a warning is given to the user. else theself._calibrator
is initialized with thecalibrator
inputFinally:
In all the others default stimuli the
_calibrator
object is used instead of_experiment.calibrator