Skip to content

Commit

Permalink
changed other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenichi-maeda committed Jun 12, 2024
1 parent c1fe167 commit a24db4e
Show file tree
Hide file tree
Showing 14 changed files with 725 additions and 74 deletions.
16 changes: 7 additions & 9 deletions tests/test_abbottstjudeactivetip6142_6145.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from ossdbs.electrodes import AbbottStJudeActiveTip6142_6145
from .geometry_converter import GeometryConverter
import pytest
import netgen
import ngsolve
import json
import os
import numpy as np


Expand All @@ -24,7 +21,8 @@ class TestAbbottStJudeActiveTip6142_6145():
((0.0, (1, -2, 3), (0, 0, 0)), FILE_PREFIX + '_1.json'),
((30.0, (1, -2, 3), (0, 0, 0)), FILE_PREFIX + '_1.json'),
((0.0, (1, -2, 3), (2.0, 0, 1.0)), FILE_PREFIX + '_2.json'),
((0.0, (1, -2, 3), (2.0 / 3.0, 0, 1.0 / 3.0)), FILE_PREFIX + '_2.json'),
((0.0, (1, -2, 3), (2.0 / 3.0, 0, 1.0 / 3.0)), FILE_PREFIX +
'_2.json'),
]
def load_geometry_data(self, path: str) -> dict:
Expand Down Expand Up @@ -71,18 +69,18 @@ def test_rename_boundaries(self, AbbottStJudeActiveTip6142_6145_electrode):
'Contact_4'])
assert desired == set(mesh.GetBoundaries())

# Test number and names of contacts
# Test the number and names of contacts
def test_contacts(self, AbbottStJudeActiveTip6142_6145_electrode):
electrode = AbbottStJudeActiveTip6142_6145_electrode
geometry = electrode.geometry
netgen_geometry = netgen.occ.OCCGeometry(geometry)
with ngsolve.TaskManager():
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh())
desired = set(['Body',
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4'])
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4'])
assert desired == set(mesh.GetBoundaries())

# Test volume of the entire electrode
Expand Down
60 changes: 55 additions & 5 deletions tests/test_abbottstjudeactivetip6146_6149.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from ossdbs.electrodes import AbbottStJudeActiveTip6146_6149
from .geometry_converter import GeometryConverter
import pytest
import netgen
import ngsolve
import json
import os
import numpy as np


class TestAbbottStJudeActiveTip6146_6149():
Expand Down Expand Up @@ -48,8 +46,14 @@ def test_geometry_default(self):
assert desired == GeometryConverter(geometry).to_dictionary()
"""
def test_rename_boundaries(self):
electrode = AbbottStJudeActiveTip6146_6149()

@pytest.fixture
def AbbottStJudeActiveTip6146_6149_electrode(self):
return AbbottStJudeActiveTip6146_6149()

# Test whether set_contact_names() works
def test_rename_boundaries(self, AbbottStJudeActiveTip6146_6149_electrode):
electrode = AbbottStJudeActiveTip6146_6149_electrode
electrode.set_contact_names({'Body': 'RenamedBody',
'Contact_1': 'RenamedContact_1',
'NonExistingPart': 'NonExistingPart'})
Expand All @@ -64,6 +68,52 @@ def test_rename_boundaries(self):
'Contact_4'])
assert desired == set(mesh.GetBoundaries())

# Test the number and names of contacts
def test_contacts(self, AbbottStJudeActiveTip6146_6149_electrode):
electrode = AbbottStJudeActiveTip6146_6149_electrode
geometry = electrode.geometry
netgen_geometry = netgen.occ.OCCGeometry(geometry)
with ngsolve.TaskManager():
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh())
desired = set(['Body',
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4'])
assert desired == set(mesh.GetBoundaries())

# Test volume of the entire electrode
def test_electrode_volume(self, AbbottStJudeActiveTip6146_6149_electrode):
electrode = AbbottStJudeActiveTip6146_6149_electrode

total_length = electrode._parameters.total_length
tip_length = electrode._parameters.tip_length
radius = electrode._parameters.lead_diameter * 0.5
height = total_length - tip_length

desired = (np.pi * radius ** 2 * height) + (4 / 3 * np.pi * radius ** 3 * 0.5)
actual = electrode.geometry.mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)

# Test volume of all the contacts
def test_contacts_volume(self, AbbottStJudeActiveTip6146_6149_electrode):
electrode = AbbottStJudeActiveTip6146_6149_electrode

contact_length = electrode._parameters.contact_length
radius = electrode._parameters.lead_diameter * 0.5
n_contacts = electrode._n_contacts

C1_height = electrode._parameters.tip_length - radius
C1_volume = (4 / 3 * radius ** 3 * np.pi * 0.5) + (C1_height * radius ** 2 * np.pi)

desired = (contact_length * radius ** 2 * np.pi) * (n_contacts - 1) + C1_volume
actual = electrode._contacts().mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)


"""
class TestAbbottStJudeActiveTip6146_6149_Capsule():
Expand Down
63 changes: 58 additions & 5 deletions tests/test_abbottstjudedirected6172.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from ossdbs.electrodes import AbbottStJudeDirected6172
from .geometry_converter import GeometryConverter
import pytest
import netgen
import ngsolve
import json
import os
import numpy as np


class TestAbbottStJudeDirected6172():
Expand Down Expand Up @@ -48,8 +46,14 @@ def test_geometry_default(self):
assert desired == GeometryConverter(geometry).to_dictionary()
"""
def test_rename_boundaries(self):
electrode = AbbottStJudeDirected6172()

@pytest.fixture
def AbbottStJudeDirected6172_electrode(self):
return AbbottStJudeDirected6172()

# Test whether set_contact_names() works
def test_rename_boundaries(self, AbbottStJudeDirected6172_electrode):
electrode = AbbottStJudeDirected6172_electrode
electrode.set_contact_names({'Body': 'RenamedBody',
'Contact_1': 'RenamedContact_1',
'NonExistingPart': 'NonExistingPart'})
Expand All @@ -69,6 +73,55 @@ def test_rename_boundaries(self):
])
assert desired == set(mesh.GetBoundaries())

# Test the number and names of contacts
def test_contacts(self, AbbottStJudeDirected6172_electrode):
electrode = AbbottStJudeDirected6172_electrode
geometry = electrode.geometry
netgen_geometry = netgen.occ.OCCGeometry(geometry)
with ngsolve.TaskManager():
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh())
desired = set(['Body',
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4',
'Contact_5',
'Contact_6',
'Contact_7',
'Contact_8'
])
assert desired == set(mesh.GetBoundaries())

# Test volume of the entire electrode
def test_electrode_volume(self, AbbottStJudeDirected6172_electrode):
electrode = AbbottStJudeDirected6172_electrode

total_length = electrode._parameters.total_length
tip_length = electrode._parameters.tip_length
radius = electrode._parameters.lead_diameter * 0.5
height = total_length - tip_length

desired = (np.pi * radius ** 2 * height) + (4 / 3 * np.pi * radius ** 3 * 0.5)
actual = electrode.geometry.mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)

# Test volume of all the contacts
def test_contacts_volume(self, AbbottStJudeDirected6172_electrode):
electrode = AbbottStJudeDirected6172_electrode

contact_length = electrode._parameters.contact_length
radius = electrode._parameters.lead_diameter * 0.5

desired = (np.pi * radius ** 2
* contact_length * 2) + (np.pi * radius ** 2 * contact_length * 90/360) * 6

actual = electrode._contacts().mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)


"""
class TestAbbottStJudeDirected6172_Capsule():
Expand Down
62 changes: 57 additions & 5 deletions tests/test_abbottstjudedirected6173.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from ossdbs.electrodes import AbbottStJudeDirected6173
from .geometry_converter import GeometryConverter
import pytest
import netgen
import ngsolve
import json
import os
import numpy as np


class TestAbbottStJudeDirected6173():
Expand Down Expand Up @@ -49,8 +47,14 @@ def test_geometry_default(self):
assert desired == GeometryConverter(geometry).to_dictionary()
"""
def test_rename_boundaries(self):
electrode = AbbottStJudeDirected6173()

@pytest.fixture
def AbbottStJudeDirected6173_electrode(self):
return AbbottStJudeDirected6173()

# Test whether set_contact_names() works
def test_rename_boundaries(self, AbbottStJudeDirected6173_electrode):
electrode = AbbottStJudeDirected6173_electrode
electrode.set_contact_names({'Body': 'RenamedBody',
'Contact_1': 'RenamedContact_1',
'NonExistingPart': 'NonExistingPart'})
Expand All @@ -70,6 +74,54 @@ def test_rename_boundaries(self):
])
assert desired == set(mesh.GetBoundaries())

# Test the number and names of contacts
def test_contacts(self, AbbottStJudeDirected6173_electrode):
electrode = AbbottStJudeDirected6173_electrode
geometry = electrode.geometry
netgen_geometry = netgen.occ.OCCGeometry(geometry)
with ngsolve.TaskManager():
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh())
desired = set(['Body',
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4',
'Contact_5',
'Contact_6',
'Contact_7',
'Contact_8'
])
assert desired == set(mesh.GetBoundaries())

# Test volume of the entire electrode
def test_electrode_volume(self, AbbottStJudeDirected6173_electrode):
electrode = AbbottStJudeDirected6173_electrode

total_length = electrode._parameters.total_length
tip_length = electrode._parameters.tip_length
radius = electrode._parameters.lead_diameter * 0.5
height = total_length - tip_length

desired = (np.pi * radius ** 2 * height) + (4 / 3 * np.pi * radius ** 3 * 0.5)
actual = electrode.geometry.mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)

# Test volume of all the contacts
def test_contacts_volume(self, AbbottStJudeDirected6173_electrode):
electrode = AbbottStJudeDirected6173_electrode

contact_length = electrode._parameters.contact_length
radius = electrode._parameters.lead_diameter * 0.5

desired = (np.pi * radius ** 2
* contact_length * 2) + (np.pi * radius ** 2 * contact_length * 90/360) * 6
actual = electrode._contacts().mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)


"""
class TestAbbottStJudeDirected6173_Capsule():
Expand Down
61 changes: 56 additions & 5 deletions tests/test_bostonscientificvercise.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from ossdbs.electrodes import BostonScientificVercise
from .geometry_converter import GeometryConverter
import pytest
import netgen
import ngsolve
import json
import os
import numpy as np


class TestBostonScientificVercise():
Expand Down Expand Up @@ -49,8 +47,13 @@ def test_geometry_default(self):
assert desired == GeometryConverter(geometry).to_dictionary()
"""

def test_rename_boundaries(self):
electrode = BostonScientificVercise()
@pytest.fixture
def BostonScientificVercise_electrode(self):
return BostonScientificVercise()

# Test whether set_contact_names() works
def test_rename_boundaries(self, BostonScientificVercise_electrode):
electrode = BostonScientificVercise_electrode
electrode.set_contact_names({'Body': 'RenamedBody',
'Contact_1': 'RenamedContact_1',
'NonExistingPart': 'NonExistingPart'})
Expand All @@ -69,6 +72,54 @@ def test_rename_boundaries(self):
'Contact_8'])
assert desired == set(mesh.GetBoundaries())

# Test the number and names of contacts
def test_contacts(self, BostonScientificVercise_electrode):
electrode = BostonScientificVercise_electrode
geometry = electrode.geometry
netgen_geometry = netgen.occ.OCCGeometry(geometry)
with ngsolve.TaskManager():
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh())
desired = set(['Body',
'Contact_1',
'Contact_2',
'Contact_3',
'Contact_4',
'Contact_5',
'Contact_6',
'Contact_7',
'Contact_8'
])
assert desired == set(mesh.GetBoundaries())

# Test volume of the entire electrode
def test_electrode_volume(self, BostonScientificVercise_electrode):
electrode = BostonScientificVercise_electrode

total_length = electrode._parameters.total_length
tip_length = electrode._parameters.tip_length
radius = electrode._parameters.lead_diameter * 0.5
height = total_length - tip_length

desired = (np.pi * radius ** 2 * height) + (4 / 3 * np.pi * radius ** 3 * 0.5)
actual = electrode.geometry.mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)

# Test volume of all the contacts
def test_contacts_volume(self, BostonScientificVercise_electrode):
electrode = BostonScientificVercise_electrode

contact_length = electrode._parameters.contact_length
radius = electrode._parameters.lead_diameter * 0.5
n_contacts = electrode._n_contacts

desired = (contact_length * radius ** 2 * np.pi) * n_contacts
actual = electrode._contacts().mass
tolerance = 1e-5

np.testing.assert_allclose(actual, desired, atol=tolerance)


"""
class TestBostonScientificVercise_Capsule():
Expand Down
Loading

0 comments on commit a24db4e

Please sign in to comment.