Skip to content

Commit

Permalink
Add unit test to cover multiple incoming edges
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhahmann committed Sep 12, 2024
1 parent e48a2fc commit d69d9ca
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.mastodon.mamut.feature.spot.dimensionalityreduction.umap.SpotUmapFeature;
import org.mastodon.mamut.model.Link;
import org.mastodon.mamut.model.Model;
import org.mastodon.mamut.model.ModelGraph;
import org.mastodon.mamut.model.Spot;
import org.mastodon.mamut.model.branch.BranchLink;
import org.mastodon.mamut.model.branch.BranchSpot;
Expand Down Expand Up @@ -148,4 +149,33 @@ void testPartiallyIllegalData()
assertTrue( Double.isNaN( projection0.value( graph2.spot13 ) ) );
}
}

@Test
void testMultipleIncomingEdges()
{
Model model = new Model();
ModelGraph graph = model.getGraph();
Spot spot00 = graph.addVertex().init( 0, new double[] { 0, 0, 0 }, 0 );
Spot spot01 = graph.addVertex().init( 0, new double[] { 3, 4, 0 }, 0 );
Spot spot02 = graph.addVertex().init( 0, new double[] { 6, 8, 0 }, 0 );
Spot spot1 = graph.addVertex().init( 1, new double[] { 3, 4, 0 }, 0 );
graph.addEdge( spot00, spot1 ).init();
graph.addEdge( spot01, spot1 ).init();
graph.addEdge( spot02, spot1 ).init();

try (Context context = new Context())
{
UmapController umapController = new UmapController( model, context );
FeatureModel featureModel = model.getFeatureModel();
Supplier< List< UmapInputDimension< Spot, Link > > > inputDimensionsSupplier =
() -> UmapInputDimension.getListFromFeatureModel( featureModel, Spot.class, Link.class );
umapController.computeFeature( inputDimensionsSupplier );
Feature< Spot > spotUmapFeature = Cast.unchecked( featureModel.getFeature( SpotUmapFeature.GENERIC_SPEC ) );
Set< FeatureProjection< Spot > > projections = spotUmapFeature.projections();
assertEquals( 2, projections.size() );
FeatureProjection< Spot > projection0 = spotUmapFeature.projections().iterator().next();
assertFalse( Double.isNaN( projection0.value( spot1 ) ) );
}
}

}

0 comments on commit d69d9ca

Please sign in to comment.