]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Use tolerance 1e-7 for checking volume in the Model test cases.
authorazv <azv@opencascade.com>
Sat, 1 Apr 2017 14:34:16 +0000 (17:34 +0300)
committerazv <azv@opencascade.com>
Sat, 1 Apr 2017 14:34:16 +0000 (17:34 +0300)
src/PythonAPI/model/tests/tests.py
test.models/angle30.py
test.models/wheel_rim.py

index 2cc13febd619db92e70a9ada4c5fa50429de9116..84e84c6a6d30f462f624a461c118b193cb27ead0 100644 (file)
@@ -96,11 +96,12 @@ def testNbSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
     assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
 
 
-def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 10):
+def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 7):
   """ Tests results volumes.
   :param theFeature: feature to test.
   :param theExpectedResultsVolumes: list of results volumes. Size of list should be equal to len(theFeature.results()).
   """
+  aTolerance = 10**(-theNbSignificantDigits)
   aNbResults = len(theFeature.results())
   aListSize = len(theExpectedResultsVolumes)
   assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
@@ -109,7 +110,7 @@ def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDi
     aResultVolumeStr = "{:0.27f}".format(aResultVolume).lstrip("0").lstrip(".").lstrip("0")
     anExpectedResultVolume = theExpectedResultsVolumes[anIndex]
     anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0")
-    assert (aResultVolumeStr[:theNbSignificantDigits] == anExpectedResultVolumeStr[:theNbSignificantDigits]), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
+    assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * anExpectedResultVolume, "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
 
 def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
   """ Tests if all faces of result have a name
index 2bfbcb9f29adcf4289be8fcdd1d8a32d32b5726b..ffd838e9ec5c2ceeafd5da45ced964561c48e84f 100644 (file)
@@ -184,7 +184,6 @@ SketchLine_33.setName("SketchLine_32")
 SketchLine_33.result().setName("SketchLine_32")
 SketchConstraintDistance_10 = Sketch_4.setDistance(SketchLine_22.startPoint(), SketchLine_32.result(), 4.5)
 SketchConstraintDistance_10.setName("SketchConstraintDistance_13")
-SketchPoint_2 = Sketch_4.addPoint(0.0367430766441097, 12.3548825983447)
 SketchLine_34 = Sketch_4.addLine(-8.5, 12.23281708580693, 8.5, 12.23281708580693)
 SketchLine_34.setName("SketchLine_33")
 SketchLine_34.result().setName("SketchLine_33")
@@ -323,6 +322,12 @@ SketchConstraintDistance_17 = Sketch_4.setDistance(SketchLine_21.result(), Sketc
 SketchConstraintDistance_17.setName("SketchConstraintDistance_18")
 SketchConstraintDistance_18 = Sketch_4.setDistance(SketchLine_30.endPoint(), SketchLine_20.result(), 6.1)
 SketchConstraintDistance_18.setName("SketchConstraintDistance_19")
+SketchConstraintCoincidence_67 = Sketch_4.setCoincident(SketchArc_3.center(), SketchCircle_3.center())
+SketchConstraintCoincidence_67.setName("SketchConstraintCoincidence_149")
+SketchConstraintCoincidence_68 = Sketch_4.setCoincident(SketchArc_4.center(), SketchArc_3.center())
+SketchConstraintCoincidence_68.setName("SketchConstraintCoincidence_150")
+SketchConstraintDistance_19 = Sketch_4.setDistance(SketchArc_4.center(), SketchLine_34.result(), 12)
+SketchConstraintDistance_19.setName("SketchConstraintDistance_43")
 model.do()
 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), 50, 30)
 Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 22, 22)
@@ -753,9 +758,9 @@ from GeomAPI import GeomAPI_Shape
 model.testNbResults(Boolean_7, 1)
 model.testNbSubResults(Boolean_7, [0])
 model.testNbSubShapes(Boolean_7, GeomAPI_Shape.SOLID, [1])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [49])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [263])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [526])
-model.testResultsVolumes(Boolean_7, [157000.328896829247241839766502380])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [50])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [266])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [532])
+model.testResultsVolumes(Boolean_7, [156999.218330596777377650141716003])
 
 assert(model.checkPythonDump)
index bb803520362bfb4fbcce27c3110f16c6621dff4a..641060991b09ed64a3dfb11cb7d4e39e2a641989 100644 (file)
@@ -244,6 +244,6 @@ model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [35])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [162])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [324])
-model.testResultsVolumes(Boolean_1, [2053931.555419394280761480331420898])
+model.testResultsVolumes(Boolean_1, [2053931.913933836854994297027587891])
 
 assert(model.checkPythonDump())