Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit e2529da

Browse files
author
Jaquier Aurélien Tristan
committed
fix tests
1 parent e8eeecb commit e2529da

File tree

8 files changed

+33
-20
lines changed

8 files changed

+33
-20
lines changed

bluepyopt/ephys/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ def instantiate(self, sim=None):
686686
nsegs_method=None,
687687
)
688688

689-
self.lfpy_electrode = RecExtElectrode(self.lfpy_cell, probe=self.electrode)
689+
self.lfpy_electrode = RecExtElectrode(
690+
self.lfpy_cell, probe=self.electrode
691+
)
690692

691693
if self.mechanisms is not None:
692694
for mechanism in self.mechanisms:

bluepyopt/ephys/protocols.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def _run_func(self, cell_model, param_values, sim=None):
206206
tstop=self.total_duration,
207207
cvode_active=self.cvode_active)
208208
else:
209-
sim.run(tstop=self.total_duration, cvode_active=self.cvode_active)
209+
sim.run(
210+
self.total_duration, cvode_active=self.cvode_active
211+
)
210212
except (RuntimeError, simulators.NrnSimulatorException):
211213
logger.debug(
212214
'SweepProtocol: Running of parameter set {%s} generated '
@@ -293,7 +295,8 @@ def instantiate(self, sim=None, cell_model=None):
293295
for recording in self.recordings:
294296
try:
295297
if isinstance(recording, LFPRecording):
296-
recording.instantiate(sim=sim, lfpy_cell=cell_model.lfpy_cell,
298+
recording.instantiate(sim=sim,
299+
lfpy_cell=cell_model.lfpy_cell,
297300
electrode=cell_model.lfpy_electrode)
298301
else:
299302
recording.instantiate(sim=sim, icell=cell_model.icell)

bluepyopt/ephys/simulators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def run(
229229
lfpy_cell.tstop = tstop
230230

231231
if dt is not None:
232-
lfpy_cell.LFPyCell.dt = dt
232+
lfpy_cell.dt = dt
233233

234234
if cvode_active and dt is not None:
235235
raise ValueError(
@@ -281,4 +281,4 @@ def __init__(self, message, original):
281281
"""Constructor"""
282282

283283
super(LFPySimulatorException, self).__init__(message)
284-
self.original = original
284+
self.original = original

bluepyopt/tests/test_ephys/test_protocols.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def test_sweepprotocol_instantiate_with_LFPyCellModel():
424424
import LFPy
425425

426426
dummy_cell = dummycells.DummyLFPyCellModel1()
427-
nrn_sim = ephys.simulators.LFPySimulator(LFPyCellModel=dummy_cell)
427+
nrn_sim = ephys.simulators.LFPySimulator()
428428

429429
soma_loc = ephys.locations.NrnSeclistCompLocation(
430430
name='soma_loc',
@@ -450,8 +450,8 @@ def test_sweepprotocol_instantiate_with_LFPyCellModel():
450450
stimuli=[stim],
451451
recordings=[rec])
452452

453-
icell, lfpy_cell = dummy_cell.instantiate(sim=nrn_sim)
454-
protocol.instantiate(sim=nrn_sim, icell=icell, LFPyCell=lfpy_cell)
453+
dummy_cell.instantiate(sim=nrn_sim)
454+
protocol.instantiate(sim=nrn_sim, cell_model=dummy_cell)
455455

456456
# check that recording and stimuli have been instantiated with LFPy
457457
assert rec.instantiated

bluepyopt/tests/test_ephys/test_recordings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ def test_lfprecording_instantiate():
103103
lfpy_cell = ephys.models.LFPyCellModel(
104104
name="lfpy_cell", morph=test_morph, mechs=[]
105105
)
106-
neuron_sim = ephys.simulators.LFPySimulator(LFPyCellModel=lfpy_cell)
106+
neuron_sim = ephys.simulators.LFPySimulator()
107107
lfpy_cell.instantiate(sim=neuron_sim)
108108

109109
recording.instantiate(
110-
sim=neuron_sim, icell=lfpy_cell.icell, LFPyCell=lfpy_cell.LFPyCell
110+
sim=neuron_sim, lfpy_cell=lfpy_cell.lfpy_cell
111111
)
112112

113113
assert recording.instantiated

bluepyopt/tests/test_ephys/test_simulators.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_lfpysimulator_init():
146146
"""ephys.simulators: test if LFPySimulator constructor works"""
147147

148148
empty_cell = ephys.models.LFPyCellModel(name="empty_cell")
149-
neuron_sim = ephys.simulators.LFPySimulator(LFPyCellModel=empty_cell)
149+
neuron_sim = ephys.simulators.LFPySimulator()
150150
assert isinstance(neuron_sim, ephys.simulators.LFPySimulator)
151151

152152

@@ -156,7 +156,7 @@ def test_lfpyimulator_init_windows():
156156

157157
with mock.patch('platform.system', mock.MagicMock(return_value="Windows")):
158158
empty_cell = ephys.models.LFPyCellModel(name="empty_cell")
159-
neuron_sim = ephys.simulators.LFPySimulator(LFPyCellModel=empty_cell)
159+
neuron_sim = ephys.simulators.LFPySimulator()
160160
assert isinstance(neuron_sim, ephys.simulators.LFPySimulator)
161161
assert not neuron_sim.disable_banner
162162
assert not neuron_sim.banner_disabled
@@ -172,7 +172,7 @@ def test__lfpysimulator_neuron_import():
172172
"""ephys.simulators: test neuron import from LFPySimulator"""
173173
from bluepyopt import ephys # NOQA
174174
empty_cell = ephys.models.LFPyCellModel(name="empty_cell")
175-
neuron_sim = ephys.simulators.LFPySimulator(LFPyCellModel=empty_cell)
175+
neuron_sim = ephys.simulators.LFPySimulator()
176176
assert isinstance(neuron_sim.neuron, types.ModuleType)
177177

178178

@@ -190,7 +190,7 @@ def test_lfpysim_run_cvodeactive_dt_exception():
190190
lfpy_cell = ephys.models.LFPyCellModel(
191191
name="lfpy_cell", morph=test_morph, mechs=[]
192192
)
193-
neuron_sim = ephys.simulators.LFPySimulator(LFPyCellModel=lfpy_cell)
193+
neuron_sim = ephys.simulators.LFPySimulator()
194194
lfpy_cell.instantiate(sim=neuron_sim)
195195

196196
with pytest.raises(
@@ -201,7 +201,13 @@ def test_lfpysim_run_cvodeactive_dt_exception():
201201
'cvode_active is True in the NrnSimulator run method'
202202
),
203203
):
204-
neuron_sim.run(10, dt=0.1, cvode_active=True)
204+
neuron_sim.run(
205+
tstop=10,
206+
dt=0.1,
207+
cvode_active=True,
208+
lfpy_cell=lfpy_cell.lfpy_cell,
209+
lfpy_electrode=lfpy_cell.lfpy_electrode
210+
)
205211

206212
lfpy_cell.destroy(sim=neuron_sim)
207213

bluepyopt/tests/test_ephys/test_stimuli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_LFPySquarePulse_instantiate():
250250

251251
nrn_sim = ephys.simulators.NrnSimulator()
252252
dummy_cell = dummycells.DummyLFPyCellModel1()
253-
icell, lfpycell = dummy_cell.instantiate(sim=nrn_sim)
253+
_, lfpycell = dummy_cell.instantiate(sim=nrn_sim)
254254

255255
soma_loc = ephys.locations.NrnSeclistCompLocation(
256256
name=None,
@@ -266,7 +266,7 @@ def test_LFPySquarePulse_instantiate():
266266
total_duration=300
267267
)
268268

269-
stim.instantiate(sim=nrn_sim, icell=icell, LFPyCell=lfpycell)
269+
stim.instantiate(lfpy_cell=lfpycell)
270270
nrn_sim.run(stim.total_duration)
271271

272272
stim.destroy(sim=nrn_sim)

bluepyopt/tests/test_ephys/testmodels/dummycells.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def __init__(self, name=None):
7070
super(DummyLFPyCellModel1, self).__init__(name)
7171
self.persistent = []
7272
self.icell = None
73-
self.LFPyCell = None
73+
self.lfpy_cell = None
74+
self.electrode = None
75+
self.lfpy_electrode = None
7476

7577
def freeze(self, param_values):
7678
"""Freeze model"""
@@ -111,7 +113,7 @@ def __init__(self):
111113
self.persistent.append(self.icell)
112114
self.persistent.append(self.icell.soma[0])
113115

114-
self.LFPyCell = LFPy.Cell(
116+
self.lfpy_cell = LFPy.Cell(
115117
morphology=sim.neuron.h.allsec(),
116118
dt=0.025,
117119
v_init=-65,
@@ -120,7 +122,7 @@ def __init__(self):
120122
nsegs_method=None,
121123
)
122124

123-
return self.icell, self.LFPyCell
125+
return self.icell, self.lfpy_cell
124126

125127
def destroy(self, sim=None):
126128
"""Destroy cell from simulator"""

0 commit comments

Comments
 (0)