From 1e1615440cdc1d8ed61e9904e1dc59ada68993fb Mon Sep 17 00:00:00 2001 From: Richard Christie Date: Wed, 19 May 2021 18:43:47 +1200 Subject: [PATCH 1/3] Fix use of is for new python --- src/scaffoldmaker/utils/annulusmesh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scaffoldmaker/utils/annulusmesh.py b/src/scaffoldmaker/utils/annulusmesh.py index 7aac0549..d3271432 100644 --- a/src/scaffoldmaker/utils/annulusmesh.py +++ b/src/scaffoldmaker/utils/annulusmesh.py @@ -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 From 207b8d228ab06830b24cd9d36f2abeedb4a75ee0 Mon Sep 17 00:00:00 2001 From: Richard Christie Date: Wed, 19 May 2021 18:44:41 +1200 Subject: [PATCH 2/3] Fix refinement of point/mesh annotations --- src/scaffoldmaker/utils/meshrefinement.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scaffoldmaker/utils/meshrefinement.py b/src/scaffoldmaker/utils/meshrefinement.py index 38ba5871..880877f2 100644 --- a/src/scaffoldmaker/utils/meshrefinement.py +++ b/src/scaffoldmaker/utils/meshrefinement.py @@ -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 = {} From f6b3253376917d0928c42940e0f31560212e923f Mon Sep 17 00:00:00 2001 From: Richard Christie Date: Wed, 19 May 2021 18:45:52 +1200 Subject: [PATCH 3/3] Update test_general answers --- tests/test_general.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_general.py b/tests/test_general.py index 28802e53..723c82cc 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -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)) @@ -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')) @@ -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() @@ -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())