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

Add test for affinity features #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/segmentation/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ def test_apply_mask_to_grid_graph_edges_and_weights(self):
self.assertEqual(len(weights), len(edges))
self.assertGreater(n_edges_prev, len(edges))

def test_affinity_features(self):
from elf.segmentation.features import compute_rag, compute_affinity_features

offsets = [[-1, 0], [0, -1], [-3, 0], [0, -3]]

shape = (256, 256)
seg = self.make_seg(shape)
rag = compute_rag(seg)

aff_shape = (len(offsets),) + shape
inp = np.random.rand(*aff_shape).astype("float32")

feats = compute_affinity_features(rag, inp, offsets)
self.assertEqual(rag.numberOfEdges, len(feats))
self.assertFalse(np.allclose(feats, 0))


if __name__ == '__main__':
unittest.main()
Loading