Skip to content

Commit

Permalink
Fix tests for 3D wholebody2 scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
oneway1225 committed Aug 19, 2024
1 parent 212ac41 commit 678f488
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions tests/test_wholebody2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cmlibs.zinc.field import Field
from cmlibs.zinc.result import RESULT_OK

from scaffoldmaker.annotation.annotationgroup import getAnnotationGroupForTerm, AnnotationGroup
from scaffoldmaker.annotation.annotationgroup import getAnnotationGroupForTerm, findAnnotationGroupByName
from scaffoldmaker.annotation.body_terms import get_body_term
from scaffoldmaker.meshtypes.meshtype_3d_wholebody2 import MeshType_3d_wholebody2

Expand Down Expand Up @@ -92,28 +92,22 @@ def test_wholebody2_core(self):

# check some annotationGroups:
expectedSizes2d = {
"skin epidermis": 308
"skin epidermis": (308, 35.880031911102506)
}
for name in expectedSizes2d:
term = get_body_term(name)
annotationGroup = getAnnotationGroupForTerm(annotationGroups, term)
size = annotationGroup.getMeshGroup(mesh2d).getSize()
self.assertEqual(expectedSizes2d[name], size, name)

surfaceGroup = AnnotationGroup(region, term)
isExterior = fieldmodule.createFieldIsExterior()
isExteriorXi3_1 = fieldmodule.createFieldAnd(
isExterior, fieldmodule.createFieldIsOnFace(Element.FACE_TYPE_XI3_1))
surfaceMeshGroup = surfaceGroup.getMeshGroup(mesh2d)
surfaceMeshGroup.addElementsConditional(isExteriorXi3_1)
self.assertEqual(expectedSizes2d[name][0], size, name)

surfaceMeshGroup = annotationGroup.getMeshGroup(mesh2d)
surfaceAreaField = fieldmodule.createFieldMeshIntegral(one, coordinates, surfaceMeshGroup)
surfaceAreaField.setNumbersOfPoints(4)

fieldcache = fieldmodule.createFieldcache()
result, surfaceArea = surfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(surfaceArea, 35.880031911102506, delta=tol)
self.assertAlmostEqual(surfaceArea, expectedSizes2d[name][1], delta=tol)


def test_wholebody2_tube(self):
Expand Down Expand Up @@ -199,28 +193,22 @@ def test_wholebody2_tube(self):

# check some annotationGroups:
expectedSizes2d = {
"skin epidermis": 308
"skin epidermis": (308, 35.880031911102506)
}
for name in expectedSizes2d:
term = get_body_term(name)
annotationGroup = getAnnotationGroupForTerm(annotationGroups, term)
size = annotationGroup.getMeshGroup(mesh2d).getSize()
self.assertEqual(expectedSizes2d[name], size, name)

surfaceGroup = AnnotationGroup(region, term)
isExterior = fieldmodule.createFieldIsExterior()
isExteriorXi3_1 = fieldmodule.createFieldAnd(
isExterior, fieldmodule.createFieldIsOnFace(Element.FACE_TYPE_XI3_1))
surfaceMeshGroup = surfaceGroup.getMeshGroup(mesh2d)
surfaceMeshGroup.addElementsConditional(isExteriorXi3_1)
self.assertEqual(expectedSizes2d[name][0], size, name)

surfaceMeshGroup = annotationGroup.getMeshGroup(mesh2d)
surfaceAreaField = fieldmodule.createFieldMeshIntegral(one, coordinates, surfaceMeshGroup)
surfaceAreaField.setNumbersOfPoints(4)

fieldcache = fieldmodule.createFieldcache()
result, surfaceArea = surfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(surfaceArea, 35.880031911102506, delta=tol)
self.assertAlmostEqual(surfaceArea, expectedSizes2d[name][1], delta=tol)


if __name__ == "__main__":
Expand Down

0 comments on commit 678f488

Please sign in to comment.