def testConvenienceFunctions(self):
        """
        Verify that OperatorSubView.viewed_operator() and OperatorSubView.current_view_index() work correctly.
        """
        graph = Graph()
        opWrappedSum = OperatorWrapper( OpSum, graph=graph )
        opWrappedSum.InputA.resize(3)
            
        subView1 = OperatorSubView(opWrappedSum, 1)
        assert subView1.viewed_operator() == opWrappedSum
        assert subView1.current_view_index() == 1

        opWrappedSum.InputA.removeSlot(0, finalsize=2)
        assert subView1.viewed_operator() == opWrappedSum
        assert subView1.current_view_index() == 0
Example #2
0
    def testOther(self):
        graph = Graph()
        opMultiThreshold = OpMultiThreshold(graph=graph)
        opMultiThreshold.Inputs.resize(3)
        opMultiThreshold.Outputs.resize(3)

        subThresholdView = OperatorSubView(opMultiThreshold, 1)

        assert subThresholdView.Inputs == opMultiThreshold.Inputs[1]
        assert subThresholdView.Outputs == opMultiThreshold.Outputs[1]
        assert subThresholdView.hello == opMultiThreshold.hello
Example #3
0
    def testBasic(self):
        graph = Graph()
        opWrappedSum = OperatorWrapper(OpSum, graph=graph)
        opWrappedSum.InputA.resize(3)

        subView0 = OperatorSubView(opWrappedSum, 0)
        assert subView0.InputA == opWrappedSum.InputA[0]
        assert subView0.InputB == opWrappedSum.InputB[0]
        assert subView0.Output == opWrappedSum.Output[0]
        assert subView0.rand == opWrappedSum.innerOperators[0].rand

        subView1 = OperatorSubView(opWrappedSum, 1)
        assert subView1.InputA == opWrappedSum.InputA[1]
        assert subView1.InputB == opWrappedSum.InputB[1]
        assert subView1.Output == opWrappedSum.Output[1]
        assert subView1.rand == opWrappedSum.innerOperators[1].rand

        # When a slot is removed, the view should follow the same slots as they slide down the list.
        opWrappedSum.InputA.removeSlot(0, 2)
        assert subView1.InputA == opWrappedSum.InputA[0]
        assert subView1.InputB == opWrappedSum.InputB[0]
        assert subView1.Output == opWrappedSum.Output[0]
        assert subView1.rand == opWrappedSum.innerOperators[0].rand
Example #4
0
    def testConvenienceFunctions(self):
        """
        Verify that OperatorSubView.viewed_operator() and OperatorSubView.current_view_index() work correctly.
        """
        graph = Graph()
        opWrappedSum = OperatorWrapper(OpSum, graph=graph)
        opWrappedSum.InputA.resize(3)

        subView1 = OperatorSubView(opWrappedSum, 1)
        assert subView1.viewed_operator() == opWrappedSum
        assert subView1.current_view_index() == 1

        opWrappedSum.InputA.removeSlot(0, finalsize=2)
        assert subView1.viewed_operator() == opWrappedSum
        assert subView1.current_view_index() == 0
Example #5
0
    def testNested(self):
        graph = Graph()
        opNested = OpNestedMultiOps(graph=graph)
        opNested.InputA.resize(3)
        assert len(opNested.InputB) == 3

        opNestedView = OperatorSubView(opNested, 1)

        assert opNestedView.opSum1.rand == opNested.opSum1.innerOperators[
            1].rand
        assert opNestedView.opSum2.rand == opNested.opSum2.innerOperators[
            1].rand

        # View should follow the slots as they change index
        opNested.InputA.removeSlot(0, 2)
        assert opNestedView.opSum1.rand == opNested.opSum1.innerOperators[
            0].rand
        assert opNestedView.opSum2.rand == opNested.opSum2.innerOperators[
            0].rand

        assert isinstance(opNestedView.opSum1, OperatorSubView)
        assert opNestedView.opSum1.InputA.level == 0
Example #6
0
 def getLane(self, laneIndex):
     return OperatorSubView(self, laneIndex)
Example #7
0
 def getLane(self, laneIndex):
     """
     Create sub-view that exposes the correct inner operator from the base ``OperatorWrapper``.
     """
     return OperatorSubView(self, laneIndex)