Skip to content

Commit

Permalink
TST: some basic tests for default cell type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmainak committed May 5, 2021
1 parent 5d38fec commit abac3b2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hnn_core/tests/test_cell.py
@@ -1,4 +1,5 @@
import pytest
import pickle

import matplotlib

Expand Down Expand Up @@ -38,6 +39,7 @@ def test_cell():
with pytest.raises(TypeError, match='secloc must be instance of'):
cell.syn_create(0.5, e=0., tau1=0.5, tau2=5.)

pickle.dumps(cell) # check cell object is picklable until built
p_secs = {'blah': 1}
p_syn = {'ampa': dict(e=0, tau1=0.5, tau2=5.)}
topology = None
Expand Down
43 changes: 43 additions & 0 deletions hnn_core/tests/test_cells_default.py
@@ -0,0 +1,43 @@
import pytest

from neuron import h

from hnn_core.cells_default import pyramidal, basket
from hnn_core.network_builder import load_custom_mechanisms


def test_cells_default():
"""Test default cell objects."""
load_custom_mechanisms()

with pytest.raises(ValueError, match='Unknown pyramidal cell type'):
l5p = pyramidal(pos=(0, 0, 0), cell_name='blah')

l5p = pyramidal(pos=(0, 0, 0), cell_name='L5Pyr')
assert len(l5p.sections) == 9
assert 'apical_2' in l5p.sections

# smoke test to check if cell can be used in simulation
h.load_file("stdrun.hoc")
h.tstop = 40
h.dt = 0.025
h.celsius = 37

vsoma = l5p.rec_v.record(l5p.sections['soma'](0.5)._ref_v)
times = h.Vector().record(h._ref_t)

stim = h.IClamp(l5p.sections['soma'](0.5))
stim.delay = 5
stim.dur = 5.
stim.amp = 2.

h.finitialize()
h.fcurrent()
h.run()

times = times.to_python()
vsoma = vsoma.to_python()
assert len(times) == len(vsoma)

with pytest.raises(ValueError, match='Unknown basket cell type'):
l5p = basket(pos=(0, 0, 0), cell_name='blah')

0 comments on commit abac3b2

Please sign in to comment.