Skip to content

Commit d4a7945

Browse files
committed
fix invalid memory reads in tests
1 parent 3e5f523 commit d4a7945

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pytissueoptics/rayscattering/tests/opencl/src/testCLPhoton.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def testWhenMoveBy_shouldMovePhotonByTheGivenDistanceTowardsItsDirection(self):
5454
def testWhenScatterByTheta0_shouldNotChangePhotonDirection(self):
5555
phi, theta = np.pi/4, 0
5656
photonResult = self._photonFunc("scatterBy", phi, theta)
57-
self._assertVectorAlmostEqual(self.INITIAL_DIRECTION, photonResult.direction)
57+
self._assertVectorAlmostEqual(self.INITIAL_DIRECTION, photonResult.direction, places=6)
5858

5959
def testWhenScatterByThetaPi_shouldRotatePhotonDirectionToOpposite(self):
6060
phi, theta = np.pi/4, np.pi
@@ -115,7 +115,7 @@ def testWhenRefract_shouldRefractPhoton(self):
115115
photonResult = self._photonFunc("refract", incidencePlane, angleDeflection)
116116

117117
expectedDirection = Vector(0, -1, 0)
118-
self._assertVectorAlmostEqual(expectedDirection, photonResult.direction)
118+
self._assertVectorAlmostEqual(expectedDirection, photonResult.direction, places=6)
119119

120120
def testWhenRouletteWithWeightAboveThreshold_shouldIgnoreRoulette(self):
121121
weightThreshold = 1e-4
@@ -267,7 +267,7 @@ def testWhenReflectOrRefractWithRefractingIntersection_shouldRefractPhoton(self)
267267
self.INITIAL_DIRECTION = Vector(1, -1, 0)
268268
self.INITIAL_DIRECTION.normalize()
269269
insideSolidID = 9
270-
insideMaterialID = 1
270+
insideMaterialID = 0
271271
self._mockFresnelIntersection(isReflected=False, incidencePlane=Vector(0, 0, 1),
272272
angleDeflection=-np.pi / 4, nextMaterialID=insideMaterialID,
273273
nextSolidID=insideSolidID)
@@ -359,9 +359,10 @@ def testWhenStepWithIntersectionReflecting_shouldMovePhotonToIntersection(self):
359359
logger = DataPointCL(2)
360360
surfaces = SurfaceCL([SurfaceCLInfo(0, 0, 0, 0, insideSolidID=9, outsideSolidID=10, toSmooth=False)])
361361
triangles = TriangleCL([TriangleCLInfo([0, 1, 2], Vector(0, 0, 1))])
362+
vertices = VertexCL([Vertex(0, 0, 0)] * 3)
362363
photonResult = self._photonFunc(
363364
"propagateStep", stepDistance, MaterialCL([ScatteringMaterial()]),
364-
surfaces, triangles, VertexCL([]), SeedCL(1), logger, 0
365+
surfaces, triangles, vertices, SeedCL(1), logger, 0
365366
)
366367

367368
expectedPosition = self.INITIAL_POSITION + self.INITIAL_DIRECTION * intersectionDistance
@@ -376,9 +377,10 @@ def testWhenStepWithIntersectionRefracting_shouldMovePhotonToIntersection(self):
376377
logger = DataPointCL(2)
377378
surfaces = SurfaceCL([SurfaceCLInfo(0, 0, 0, 0, insideSolidID=9, outsideSolidID=10, toSmooth=False)])
378379
triangles = TriangleCL([TriangleCLInfo([0, 1, 2], Vector(0, 0, 1))])
380+
vertices = VertexCL([Vertex(0, 0, 0)] * 3)
379381
photonResult = self._photonFunc(
380382
"propagateStep", stepDistance, MaterialCL([ScatteringMaterial()]),
381-
surfaces, triangles, VertexCL([]), SeedCL(1), logger, 0
383+
surfaces, triangles, vertices, SeedCL(1), logger, 0
382384
)
383385

384386
expectedPosition = self.INITIAL_POSITION + self.INITIAL_DIRECTION * intersectionDistance

0 commit comments

Comments
 (0)