Skip to content

Commit

Permalink
make tests compatible with having correct soma (#122)
Browse files Browse the repository at this point in the history
* many "contour" soma had only a single point
  • Loading branch information
mgeplf committed Dec 15, 2023
1 parent c3b6621 commit a30b235
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 223 deletions.
Binary file modified tests/data/apical_test.h5
Binary file not shown.
5 changes: 4 additions & 1 deletion tests/data/input-convert/simple2.asc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
("CellBody"
(Color Red)
(CellBody)
(0 0 0 2)
(0.1 0 0 2)
(0 0.1 0 2)
(-0.1 0 0 2)
(0 -0.1 0 2)
)

((Dendrite)
Expand Down
5 changes: 4 additions & 1 deletion tests/data/input-convert/simple3.asc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
("CellBody"
(Color Red)
(CellBody)
(0 0 0 2)
( 0.1 0 0 2)
( 0.1 0.1 0 2)
(-0.1 0 0 2)
(-0.1 -0.1 0 2)
)

((Dendrite)
Expand Down
26 changes: 26 additions & 0 deletions tests/data/nrnhines.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
((Dendrite)
(0 0 0 2)
(0 5 0 2)
(
(-5 5 0 3)
(-6 5 0 3)
(
(-7 5 0 3)
|
(-8 10 0 3)
)
|
(6 5 0 3)
)
)


((Axon)
(0 0 0 2)
(0 -4 0 2)
(
(6 -4 0 4)
|
(-5 -4 0 4)
)
)
5 changes: 4 additions & 1 deletion tests/data/simple.asc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
("CellBody"
(Color Red)
(CellBody)
(0 0 0 2)
( 0.1 0 0 2)
( 0.1 0.1 0 2)
(-0.1 0 0 2)
(-0.1 -0.1 0 2)
)

((Dendrite)
Expand Down
Binary file modified tests/data/simple.h5
Binary file not shown.
5 changes: 4 additions & 1 deletion tests/data/simple2.asc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
("CellBody"
(Color Red)
(CellBody)
(0 0 0 2)
( 0.1 0 0 2)
( 0.1 0.1 0 2)
(-0.1 0 0 2)
(-0.1 -0.1 0 2)
)

((Dendrite)
Expand Down
5 changes: 4 additions & 1 deletion tests/data/simple3.asc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
("CellBody"
(Color Red)
(CellBody)
(0 0 0 2)
( 2 0 0 2)
( 0 2 0 2)
(-2 0 0 2)
( 0 -2 0 2)
)

((Dendrite)
Expand Down
5 changes: 4 additions & 1 deletion tests/data/synthesized_cell.asc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
("CellBody"
(Color Red)
(CellBody)
(5 5 5 1)
(5.5 5 5 1)
(5 5.5 5 1)
(4.5 5 5 1)
(5 4.5 5 1)
)

((Dendrite)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_convert_file(tmpdir):

def test_convert_folder(tmpdir):
runner = CliRunner()
result = runner.invoke(cli, ['convert', 'folder', '-ext', 'swc',
result = runner.invoke(cli, ['convert', 'folder', '--single-point-soma', '-ext', 'swc',
str(DATA / 'input-convert'), str(tmpdir)])
assert result.exit_code == 0, result.exc_info

Expand Down
7 changes: 5 additions & 2 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@


def test_convert(tmpdir):
for in_ext, out_ext in it.product(['asc', 'h5', 'swc'], repeat=2):
for in_ext, out_ext in (('asc', 'h5'),
('asc', 'swc'),
('h5', 'asc'),
('h5', 'swc')):
# A simple morphology
inname = DATA / f'simple.{in_ext}'
outname = Path(tmpdir, f'test.{out_ext}')
convert(inname, outname)
convert(inname, outname, single_point_soma=(out_ext == 'swc'))
assert not diff(inname, outname)

# A more complex one
Expand Down
1 change: 1 addition & 0 deletions tests/test_graft.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_graft_axon_on_synthesized_cell():
[[5.1272364, 5.4825425, 4.9689593],
[5.1272364, 1.4825425, 4.9689593]])


def test_self_graft():
'''Grafting a neuron with its own neuron'''
filename = DATA / 'neuron.asc'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_nrnhines.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import morph_tool.nrnhines as tested

DATA = Path(__file__).parent / 'data'
SIMPLE = DATA / 'simple2.asc'
SIMPLE = DATA / 'nrnhines.asc'


def test_interpolate_compartments():
Expand Down Expand Up @@ -46,11 +46,11 @@ def test_point_to_section_end():
assert (tested.point_to_section_end(cell.icell.all, [-8, 10, 0]) ==
6)

assert (tested.point_to_section_end(cell.icell.all, [-8, 10, 2]) ==
assert (tested.point_to_section_end(cell.icell.all, [-8, 10, 2]) is
None)

assert (tested.point_to_section_end(cell.icell.all, [-8, 10, 2],
atol=10) ==
atol=8) ==
3)


Expand Down

0 comments on commit a30b235

Please sign in to comment.