-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to remove recordings
- Loading branch information
1 parent
54a8928
commit 4bda20c
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import jax | ||
|
||
jax.config.update("jax_enable_x64", True) | ||
jax.config.update("jax_platform_name", "cpu") | ||
|
||
import jax.numpy as jnp | ||
|
||
import neurax as nx | ||
|
||
|
||
def test_record_and_stimulate_api(): | ||
"""Test the API for recording and stimulating.""" | ||
nseg_per_branch = 2 | ||
depth = 2 | ||
parents = [-1] + [b // 2 for b in range(0, 2**depth - 2)] | ||
parents = jnp.asarray(parents) | ||
num_branches = len(parents) | ||
|
||
comp = nx.Compartment().initialize() | ||
branch = nx.Branch([comp for _ in range(nseg_per_branch)]).initialize() | ||
cell = nx.Cell([branch for _ in range(num_branches)], parents=parents).initialize() | ||
|
||
cell.branch(0).comp(0.0).record() | ||
cell.branch(1).comp(1.0).record() | ||
|
||
current = nx.step_current(0.0, 1.0, 1.0, 0.025, 3.0) | ||
cell.branch(1).comp(1.0).stimulate(current) | ||
|
||
cell.delete_recordings() | ||
cell.delete_stimuli() | ||
|
||
|
||
def test_record_shape(): | ||
"""Test the API for recording and stimulating.""" | ||
nseg_per_branch = 2 | ||
depth = 2 | ||
parents = [-1] + [b // 2 for b in range(0, 2**depth - 2)] | ||
parents = jnp.asarray(parents) | ||
num_branches = len(parents) | ||
|
||
comp = nx.Compartment().initialize() | ||
branch = nx.Branch([comp for _ in range(nseg_per_branch)]).initialize() | ||
cell = nx.Cell([branch for _ in range(num_branches)], parents=parents).initialize() | ||
|
||
current = nx.step_current(0.0, 1.0, 1.0, 0.025, 3.0) | ||
cell.branch(1).comp(1.0).stimulate(current) | ||
|
||
cell.branch(0).comp(0.0).record() | ||
cell.branch(1).comp(1.0).record() | ||
cell.branch(0).comp(1.0).record() | ||
cell.delete_recordings() | ||
cell.branch(2).comp(0.5).record() | ||
cell.branch(1).comp(0.1).record() | ||
|
||
voltages = nx.integrate(cell) | ||
assert ( | ||
voltages.shape[0] == 2 | ||
), f"Shape of recordings ({voltages.shape}) is not right." |