Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_point_level():
a = PointLevel([[1, 2, 3]], [2], [])
assert_equal(a.points, [[1, 2, 3]])
assert_equal(a.diameters, [2])
with assert_raises(SectionBuilderError) as obj:
a = PointLevel([[1, 2, 3],
[1, 2, 3]],
[2],
[])
assert_substring("Point vector have size: 2 while Diameter vector has size: 1",
str(obj.exception))
with assert_raises(SectionBuilderError) as obj:
a = PointLevel([[1, 2, 3],
[1, 2, 3]],
[2, 3],
[4])
assert_substring("Point vector have size: 2 while Perimeter vector has size: 1",
str(obj.exception))
def test_single_point_root_section():
m = Morphology()
points = []
diameters = []
# Too hide the warning: appending empty section
with captured_output():
with ostream_redirect(stdout=True, stderr=True):
m.append_root_section(PointLevel(points, diameters), SectionType(2))
with setup_tempdir('test_single_point_root_section', no_cleanup=True) as tmp_folder:
assert_raises(SectionBuilderError, m.write, os.path.join(tmp_folder, "h5/empty_vasculature.h5"))
m = Morphology()
points = [[1., 1., 1.]]
diameters = [2.]
m.append_root_section(PointLevel(points, diameters), SectionType(2))
with setup_tempdir('test_single_point_root_section', no_cleanup=True) as tmp_folder:
assert_raises(SectionBuilderError, m.write, os.path.join(tmp_folder, "h5/empty_vasculature.h5"))
def test_point_level():
a = PointLevel([[1, 2, 3]], [2], [])
assert_equal(a.points, [[1, 2, 3]])
assert_equal(a.diameters, [2])
with assert_raises(SectionBuilderError) as obj:
a = PointLevel([[1, 2, 3],
[1, 2, 3]],
[2],
[])
assert_substring("Point vector have size: 2 while Diameter vector has size: 1",
str(obj.exception))
with assert_raises(SectionBuilderError) as obj:
a = PointLevel([[1, 2, 3],
[1, 2, 3]],
[2, 3],
[4])
assert_substring("Point vector have size: 2 while Perimeter vector has size: 1",
str(obj.exception))
# Too hide the warning: appending empty section
with captured_output():
with ostream_redirect(stdout=True, stderr=True):
m.append_root_section(PointLevel(points, diameters), SectionType(2))
with setup_tempdir('test_single_point_root_section', no_cleanup=True) as tmp_folder:
assert_raises(SectionBuilderError, m.write, os.path.join(tmp_folder, "h5/empty_vasculature.h5"))
m = Morphology()
points = [[1., 1., 1.]]
diameters = [2.]
m.append_root_section(PointLevel(points, diameters), SectionType(2))
with setup_tempdir('test_single_point_root_section', no_cleanup=True) as tmp_folder:
assert_raises(SectionBuilderError, m.write, os.path.join(tmp_folder, "h5/empty_vasculature.h5"))