Skip to content

Commit

Permalink
store first stim value; update docs overview
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnsen committed Oct 11, 2023
1 parent 2f73f40 commit 6099220
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 10 deletions.
9 changes: 7 additions & 2 deletions cleo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,16 @@ class Stimulator(InterfaceDevice, NeoExportable):

def __attrs_post_init__(self):
self.value = self.default_value
self._init_saved_vars()

def _init_saved_vars(self):
if self.save_history:
self.t_ms = []
self.values = []
if self.sim:
t0 = self.sim.network.t / ms
else:
t0 = 0
self.t_ms = [t0]
self.values = [self.value]

def update(self, ctrl_signal) -> None:
"""Set the stimulator value.
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

autosectionlabel_prefix_document = True

jupyter_execute_notebooks = "off"
execution_excludepatterns = ["*ldsctrlest*"]
jupyter_execute_notebooks = "cache"
execution_excludepatterns = ["tutorials/*"]

# napoleon_custom_sections = "Visualization Keyword Arguments"
napoleon_custom_sections = [("Visualization kwargs", "params_style")]
Expand Down
276 changes: 276 additions & 0 deletions docs/overview.md

Large diffs are not rendered by default.

34 changes: 33 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cleosim"
version = "0.10.0"
version = "0.11.0"
description = "Cleo: the Closed-Loop, Electrophysiology, and Optogenetics experiment simulation testbed"
authors = [
"Kyle Johnsen <[email protected]>",
Expand Down Expand Up @@ -46,6 +46,7 @@ furo = "^2022.6.21"
nbdev = "^2.3.12"
elephant = "^0.13.0"
seaborn = "^0.13.0"
jupytext = "^1.15.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion tests/ioproc/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def process(self, state_dict: dict, sample_time_ms: float) -> Tuple[dict, float]


def _test_LatencyIOProcessor(myLIOP, t, sampling, inputs, outputs):
expected_out = [None if out is None else {"out": out} for out in outputs]
for i in range(len(t)):
assert myLIOP.is_sampling_now(t[i]) == sampling[i]
if myLIOP.is_sampling_now(t[i]):
myLIOP.put_state({"in": inputs[i]}, t[i])
expected_out = [out if out is None else {"out": out} for out in outputs]
assert myLIOP.get_ctrl_signal(t[i]) == expected_out[i]


Expand Down
6 changes: 3 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def test_stimulator(sim, neurons):
assert my_stim.value == 42
my_stim.update(43)
assert my_stim.value == 43
assert len(my_stim.values) == len(my_stim.t_ms) == 1 # from update
assert len(my_stim.values) == len(my_stim.t_ms) == 2 # from update

sim.update_stimulators({"my_stim": 42})
assert my_stim.value == 42
assert len(my_stim.values) == len(my_stim.t_ms) == 2 # from 2 updates
assert len(my_stim.values) == len(my_stim.t_ms) == 3 # from 2 updates

my_stim.reset()
assert len(my_stim.values) == len(my_stim.t_ms) == 0 # init
assert len(my_stim.values) == len(my_stim.t_ms) == 1 # init

neurons2 = NeuronGroup(1, "v = -70*mV : volt")
with pytest.raises(Exception): # neuron2 not in network
Expand Down

0 comments on commit 6099220

Please sign in to comment.