Skip to content

Commit

Permalink
Add convex hull tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Jul 6, 2015
1 parent 1275a1f commit f2e89e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gala/features/convex_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def convex_hull_ind(self, g, n1, n2=None):
else:
m.ravel()[list(g.extent(n1))] = 1
m = m - nd.binary_erosion(m) #Only need border
ind = np.np.array(np.nonzero(m)).T
ind = np.array(np.nonzero(m)).T
return ind


Expand Down
11 changes: 11 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ def test_2channel_composite_feature():
'toy-data/test-04-composite-2channel-12-13.pck'), 2)


def test_convex_hull():
ws = np.array([[1, 2, 2],
[1, 1, 2],
[1, 2, 2]], dtype=np.uint8)
chull = features.convex_hull.Manager()
g = agglo.Rag(ws, feature_manager=chull)
expected = np.array([0.5, 0.125, 0.5, 0.1, 1., 0.167, 0.025, 0.069,
0.44, 0.056, 1.25, 1.5, 1.2, 0.667])
assert_allclose(chull(g, 1, 2), expected, atol=0.01, rtol=1.)


if __name__ == '__main__':
from numpy import testing
testing.run_module_suite()
Expand Down

0 comments on commit f2e89e9

Please sign in to comment.