Skip to content

Commit

Permalink
Merge pull request #141 from rchristie/python39fixes
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
rchristie authored May 19, 2021
2 parents 52bf86f + f6b3253 commit a793842
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/scaffoldmaker/utils/annulusmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def derivativeSignsToExpressionTerms(valueLabels, signs, scaleFactorIdx = None):
'''
expressionTerms = []
for i in range(len(valueLabels)):
if signs[i] is 1:
if signs[i] == 1:
expressionTerms.append((valueLabels[i], ([ scaleFactorIdx ] if scaleFactorIdx else [])))
elif signs[i] is -1:
elif signs[i] == -1:
expressionTerms.append((valueLabels[i], ([1, scaleFactorIdx] if scaleFactorIdx else [1])))
return expressionTerms

Expand Down
7 changes: 5 additions & 2 deletions src/scaffoldmaker/utils/meshrefinement.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ def __init__(self, sourceRegion, targetRegion, sourceAnnotationGroups = []):
for sourceAnnotationGroup in sourceAnnotationGroups:
targetAnnotationGroup = AnnotationGroup(self._targetRegion, sourceAnnotationGroup.getTerm())
self._annotationGroups.append(targetAnnotationGroup)
self._sourceAndTargetMeshGroups.append( ( sourceAnnotationGroup.getMeshGroup(self._sourceMesh), targetAnnotationGroup.getMeshGroup(self._targetMesh)) )
self._sourceAndTargetNodesetGroups.append( ( sourceAnnotationGroup.getNodesetGroup(self._sourceNodes), targetAnnotationGroup.getNodesetGroup(self._targetNodes)) )
# assume have only highest dimension element or node/point annotation groups:
if sourceAnnotationGroup.hasMeshGroup(self._sourceMesh):
self._sourceAndTargetMeshGroups.append( ( sourceAnnotationGroup.getMeshGroup(self._sourceMesh), targetAnnotationGroup.getMeshGroup(self._targetMesh)) )
else:
self._sourceAndTargetNodesetGroups.append( ( sourceAnnotationGroup.getNodesetGroup(self._sourceNodes), targetAnnotationGroup.getNodesetGroup(self._targetNodes)) )

# prepare element -> marker point list map
self.elementMarkerMap = {}
Expand Down
8 changes: 4 additions & 4 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_user_annotation_groups(self):
scaffoldPackage.generate(region)

annotationGroups = scaffoldPackage.getAnnotationGroups()
self.assertEqual(19, len(annotationGroups))
self.assertEqual(22, len(annotationGroups))

endocardium_of_la = scaffoldPackage.findAnnotationGroupByName('endocardium of left atrium')
self.assertTrue(isinstance(endocardium_of_la, AnnotationGroup))
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_user_annotation_groups(self):
self.assertEqual('group2', annotationGroup3.getName()) # default name
self.assertTrue(scaffoldPackage.isUserAnnotationGroup(annotationGroup3))
annotationGroups = scaffoldPackage.getAnnotationGroups()
self.assertEqual(22, len(annotationGroups))
self.assertEqual(25, len(annotationGroups))

# rename group1 to fred
self.assertTrue(annotationGroup1.setName('fred'))
Expand All @@ -154,7 +154,7 @@ def test_user_annotation_groups(self):

self.assertTrue(scaffoldPackage.deleteAnnotationGroup(annotationGroup3))
annotationGroups = scaffoldPackage.getAnnotationGroups()
self.assertEqual(21, len(annotationGroups))
self.assertEqual(24, len(annotationGroups))

# test serialisation
dct = scaffoldPackage.toDict()
Expand All @@ -168,7 +168,7 @@ def test_user_annotation_groups(self):
scaffoldPackage2.generate(region2)

annotationGroups2 = scaffoldPackage2.getAnnotationGroups()
self.assertEqual(21, len(annotationGroups2))
self.assertEqual(24, len(annotationGroups2))

annotationGroup1 = scaffoldPackage2.findAnnotationGroupByName('fred')
self.assertEqual('fred', annotationGroup1.getName())
Expand Down

0 comments on commit a793842

Please sign in to comment.