Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up Experiment dependencies inside Stimulus #72

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Added warning for deprecated function inputs
fedem-p committed Mar 1, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 4e96d167e81bbf2db157adbefad39093fdefb6f0
8 changes: 7 additions & 1 deletion stytra/stimulation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from copy import deepcopy
import warnings

from PyQt5.QtCore import pyqtSignal, QTimer, QObject
from stytra.stimulation.stimuli import Pause, DynamicStimulus
@@ -112,7 +113,12 @@ def update_protocol(self):

# pass experiment to stimuli for calibrator and asset folders:
for stimulus in self.stimuli:
stimulus.initialise_external(self.experiment, self.experiment.calibrator)
try:
stimulus.initialise_external(self.experiment, self.experiment.calibrator)
except TypeError:
stimulus.initialise_external(self.experiment)
warnings.warn("Warning: 'initialise_external' will require a calibrator input from the new update!", FutureWarning)
warnings.warn("Warning: 'initialise_external' will require a calibrator input from the new update!", DeprecationWarning)

if self.dynamic_log is None:
self.dynamic_log = DynamicLog(self.stimuli, experiment=self.experiment)
15 changes: 13 additions & 2 deletions stytra/stimulation/stimuli/generic_stimuli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import datetime
import warnings


class Stimulus:
@@ -112,7 +113,7 @@ def stop(self):
"""
pass

def initialise_external(self, experiment, calibrator = None):
def initialise_external(self, experiment, calibrator = -999):
""" Make a reference to the Experiment class inside the Stimulus.
This is required to access from inside the Stimulus class to the
Calibrator, the Pyboard, the asset directories with movies or the motor
@@ -131,8 +132,18 @@ def initialise_external(self, experiment, calibrator = None):
None

"""

if calibrator == -999:
self._calibrator = self._experiment.calibrator
warnings.warn("Warning: 'initialise_external' will require a calibrator input from the new update!", FutureWarning)
warnings.warn("Warning: 'initialise_external' will require a calibrator input from the new update!", DeprecationWarning)
else:
self._calibrator = calibrator


Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix 2

self._experiment = experiment #! TOFIX: Remove
self._calibrator = calibrator




class DynamicStimulus(Stimulus):