Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: euclidean distance field acceleration #11

Merged
merged 9 commits into from
Jul 20, 2020
Prev Previous commit
Next Next commit
test: add 3d test of free space
  • Loading branch information
william-silversmith committed Jul 20, 2020
commit 32cf78448250b3c343ddec6974d780957cfe75cb
11 changes: 10 additions & 1 deletion automated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def test_distance_field_2d_asymmetric(dtype):
field = dijkstra3d.distance_field(values, (0,1))
assert np.all(field == answer)

@pytest.mark.parametrize('free_space_radius', (0,1,2,3,4,5))
@pytest.mark.parametrize('free_space_radius', (0,1,2,3,4,5,10))
def test_euclidean_distance_field_2d(free_space_radius):
values = np.ones((2, 2), dtype=bool)

Expand Down Expand Up @@ -622,6 +622,15 @@ def test_euclidean_distance_field_2d(free_space_radius):

assert np.all(np.abs(field - answer) < 0.00001)

@pytest.mark.parametrize('point', (np.random.randint(0,256, size=(3,)),))
def test_euclidean_distance_field_3d_free_space_eqn(point):
point = tuple(point)
print(point)
values = np.ones((256, 256, 256), dtype=bool)
field_dijk = dijkstra3d.euclidean_distance_field(values, point, free_space_radius=0) # free space off
field_free = dijkstra3d.euclidean_distance_field(values, point, free_space_radius=10000) # free space 100% on

assert np.all(np.abs(field_free - field_dijk) < 0.001) # there's some difference below this

def test_compass():
field = np.array([
Expand Down