public int getIterationDepth(Map<String, Integer> inputDepths) throws IterationTypeMismatchException { // Check that all input depths are the same int depth = getChildren().get(0).getIterationDepth(inputDepths); for (IterationStrategyNode childNode : getChildren()) { if (childNode.getIterationDepth(inputDepths) != depth) { throw new IterationTypeMismatchException( "Mismatched input types for dot product node"); } } return depth; }
public int getIterationDepth(Map<String, Integer> inputDepths) throws IterationTypeMismatchException { // Check that all input depths are the same int depth = getChildAt(0).getIterationDepth(inputDepths); for (IterationStrategyNode childNode : getChildren()) { if (childNode.getIterationDepth(inputDepths) != depth) { throw new IterationTypeMismatchException( "Mismatched input types for dot product node"); } } return depth; }
public int getIterationDepth(Map<String, Integer> inputDepths) throws IterationTypeMismatchException { // Check that all input depths are the same if (isLeaf()) { // No children! throw new IterationTypeMismatchException("Dot product with no children"); } int depth = getChildAt(0).getIterationDepth(inputDepths); for (IterationStrategyNode childNode : getChildren()) { if (childNode.getIterationDepth(inputDepths) != depth) { throw new IterationTypeMismatchException( "Mismatched input types for dot product node"); } } return depth; }
@Test public void moveNodeToDifferentParent() { crossProduct1.setParent(root); crossProduct1.insert(input1); crossProduct1.insert(dotProduct1); dotProduct1.insert(input2); dotProduct1.insert(crossProduct2); // Check tree assertEquals(crossProduct2, root.getChildAt(0).getChildAt(1) .getChildAt(1)); assertEquals(Arrays.asList(input2, crossProduct2), dotProduct1 .getChildren()); crossProduct1.insert(crossProduct2, 1); assertEquals(Arrays.asList(input1, crossProduct2, dotProduct1), crossProduct1.getChildren()); assertEquals(crossProduct1, crossProduct2.getParent()); // Should no longer be in dotProduct1 assertEquals(Arrays.asList(input2), dotProduct1.getChildren()); }
@Test public void moveNodeToDifferentParent() { crossProduct1.setParent(root); crossProduct1.insert(input1); crossProduct1.insert(dotProduct1); dotProduct1.insert(input2); dotProduct1.insert(crossProduct2); // Check tree assertEquals(crossProduct2, root.getChildAt(0).getChildAt(1) .getChildAt(1)); assertEquals(Arrays.asList(input2, crossProduct2), dotProduct1 .getChildren()); crossProduct1.insert(crossProduct2, 1); assertEquals(Arrays.asList(input1, crossProduct2, dotProduct1), crossProduct1.getChildren()); assertEquals(crossProduct1, crossProduct2.getParent()); // Should no longer be in dotProduct1 assertEquals(Arrays.asList(input2), dotProduct1.getChildren()); }