Skip to content

Commit

Permalink
[tests] Add unit test for Sphere.sample_uniform()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Aug 19, 2024
1 parent ef5168f commit 4a94c3f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/commit/geom/test__sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ def test_sphere_no_corners(self):
corners = s.corners
self.assertIn('vector', corners.shape)
self.assertEqual(0, corners.shape.volume)

def test_sample_uniform(self):
for s in [Sphere(x=1, radius=.5), Sphere(x=1, y=0, radius=.5), Sphere(x=1, y=0, z=0, radius=.5)]:
u = s.sample_uniform(instance(points=200))
assert 'vector' in u.shape
math.assert_close(True, (u['x'] >= 0.5) & (u['x'] <= 1.5))
if u.vector.size > 1:
math.assert_close(True, (u['y'] >= -0.5) & (u['y'] <= 0.5))

0 comments on commit 4a94c3f

Please sign in to comment.