예제 #1
0
파일: graph.py 프로젝트: njoubert/spooky
    def draw(self):
        k = self.s
        graph = self.graph
        dep = getDeps(k)

        show_sp = not (all([d.sparsity() == k.sparsity() for d in dep]))

        if show_sp:
            op = "op"
            self.drawSparsity(k, depid=op + str(k.__hash__()))
        else:
            op = ""

        if len(dep) > 1:
            # Non-commutative operators are represented by 'record' shapes.
            # The dependencies have different 'ports' where arrows should arrive.
            s = print_operator(self.s, ["| <f%d> | " % i for i in range(len(dep))])
            if s.startswith("(|") and s.endswith("|)"):
                s = s[2:-2]

            graph.add_node(pydot.Node(op + str(k.__hash__()), label=s, shape="Mrecord"))
            for i, n in enumerate(dep):
                graph.add_edge(pydot.Edge(str(n.__hash__()), op + str(k.__hash__()) + ":f%d" % i))
        else:
            s = print_operator(k, ["."])
            self.graph.add_node(pydot.Node(op + str(k.__hash__()), label=s, shape="oval"))
            for i, n in enumerate(dep):
                self.graph.add_edge(pydot.Edge(str(n.__hash__()), op + str(k.__hash__())))
예제 #2
0
파일: graph.py 프로젝트: zxplsec/casadi
    def draw(self):
        k = self.s
        graph = self.graph
        dep = getDeps(k)
        if not (k.is_commutative()):
            # Non-commutative operators are represented by 'record' shapes.
            # The dependencies have different 'ports' where arrows should arrive.
            if len(dep) == 2:
                s = print_operator(self.s, ["| <f0> | ", " | <f1> |"])
            else:
                s = print_operator(self.s, ["| <f0> | "])
            if s.startswith("(|") and s.endswith("|)"):
                s = s[2:-2]

            graph.add_node(
                pydot.Node(str(k.__hash__()), label=s, shape='Mrecord'))
            for i, n in enumerate(dep):
                graph.add_edge(
                    pydot.Edge(str(n.__hash__()),
                               str(k.__hash__()) + ":f%d" % i))
        else:
            # Commutative operators can be represented more compactly as 'oval' shapes.
            s = print_operator(k, [".", "."])
            if s.startswith("(.") and s.endswith(".)"):
                s = s[2:-2]
            if s.startswith("(") and s.endswith(")"):
                s = s[1:-1]
            self.graph.add_node(
                pydot.Node(str(k.__hash__()), label=s, shape='oval'))
            for i, n in enumerate(dep):
                self.graph.add_edge(
                    pydot.Edge(str(n.__hash__()), str(k.__hash__())))
예제 #3
0
파일: graph.py 프로젝트: zxplsec/casadi
    def draw(self):
        k = self.s
        graph = self.graph
        dep = getDeps(k)

        show_sp = not (all([d.sparsity() == k.sparsity() for d in dep]))

        if show_sp:
            op = "op"
            self.drawSparsity(k, depid=op + str(k.__hash__()))
        else:
            op = ""

        if len(dep) > 1:
            # Non-commutative operators are represented by 'record' shapes.
            # The dependencies have different 'ports' where arrows should arrive.
            s = print_operator(self.s,
                               ["| <f%d> | " % i for i in range(len(dep))])
            if s.startswith("(|") and s.endswith("|)"):
                s = s[2:-2]

            graph.add_node(
                pydot.Node(op + str(k.__hash__()), label=s, shape='Mrecord'))
            for i, n in enumerate(dep):
                graph.add_edge(
                    pydot.Edge(str(n.__hash__()),
                               op + str(k.__hash__()) + ":f%d" % i))
        else:
            s = print_operator(k, ["."])
            self.graph.add_node(
                pydot.Node(op + str(k.__hash__()), label=s, shape='oval'))
            for i, n in enumerate(dep):
                self.graph.add_edge(
                    pydot.Edge(str(n.__hash__()), op + str(k.__hash__())))
예제 #4
0
파일: graph.py 프로젝트: andrescodas/casadi
 def draw(self):
   k = self.s
   graph = self.graph
   dep = getDeps(k)
   if not(k.is_commutative()):
     # Non-commutative operators are represented by 'record' shapes.
     # The dependencies have different 'ports' where arrows should arrive.
     if len(dep)==2:
       s = print_operator(self.s,["| <f0> | ", " | <f1> |"])
     else:
       s = print_operator(self.s,["| <f0> | "])
     if s.startswith("(|") and s.endswith("|)"):
       s=s[2:-2]
     
     graph.add_node(pydot.Node(str(k.__hash__()),label=s,shape='Mrecord'))
     for i,n in enumerate(dep):
       graph.add_edge(pydot.Edge(str(n.__hash__()),str(k.__hash__())+":f%d" % i))
   else: 
    # Commutative operators can be represented more compactly as 'oval' shapes.
     s = print_operator(k,[".", "."])
     if s.startswith("(.") and s.endswith(".)"):
       s=s[2:-2]
     if s.startswith("(") and s.endswith(")"):
       s=s[1:-1]
     self.graph.add_node(pydot.Node(str(k.__hash__()),label=s,shape='oval'))
     for i,n in enumerate(dep):
       self.graph.add_edge(pydot.Edge(str(n.__hash__()),str(k.__hash__())))
예제 #5
0
파일: graph.py 프로젝트: njoubert/spooky
 def draw(self):
     k = self.s
     graph = self.graph
     dep = getDeps(k)
     s = print_operator(k, [".", "."])
     self.graph.add_node(pydot.Node(str(k.__hash__()), label=s, shape="oval"))
     self.graph.add_edge(pydot.Edge(str(dep[0].__hash__()), str(k.__hash__())))
예제 #6
0
파일: graph.py 프로젝트: DrLiLab/optCasadi
 def draw(self):
   k = self.s
   graph = self.graph
   dep = getDeps(k)
   s = print_operator(k,[".", "."])
   self.graph.add_node(pydot.Node(str(k.__hash__()),label=s,shape='oval'))
   self.graph.add_edge(pydot.Edge(str(dep[0].__hash__()),str(k.__hash__())))
예제 #7
0
파일: graph.py 프로젝트: zxplsec/casadi
    def draw(self):
        k = self.s
        graph = self.graph
        dep = getDeps(k)

        show_sp = True

        if k.is_unary() and dep[0].sparsity() == k.sparsity():
            show_sp = False
        if k.is_binary() and dep[0].sparsity() == k.sparsity(
        ) and dep[1].sparsity() == k.sparsity():
            show_sp = False

        if show_sp:
            op = "op"
            self.drawSparsity(k, depid=op + str(k.__hash__()))
        else:
            op = ""

        if not (k.is_commutative()):
            # Non-commutative operators are represented by 'record' shapes.
            # The dependencies have different 'ports' where arrows should arrive.
            s = print_operator(self.s, ["| <f0> | ", " | <f1> |"])
            if s.startswith("(|") and s.endswith("|)"):
                s = s[2:-2]

            graph.add_node(
                pydot.Node(op + str(k.__hash__()), label=s, shape='Mrecord'))
            for i, n in enumerate(dep):
                graph.add_edge(
                    pydot.Edge(str(n.__hash__()),
                               op + str(k.__hash__()) + ":f%d" % i))
        else:
            # Commutative operators can be represented more compactly as 'oval' shapes.
            s = print_operator(k, [".", "."])
            if s.startswith("(.") and s.endswith(".)"):
                s = s[2:-2]
            if s.startswith("(") and s.endswith(")"):
                s = s[1:-1]
            self.graph.add_node(
                pydot.Node(op + str(k.__hash__()), label=s, shape='oval'))
            for i, n in enumerate(dep):
                self.graph.add_edge(
                    pydot.Edge(str(n.__hash__()), op + str(k.__hash__())))
예제 #8
0
파일: graph.py 프로젝트: njoubert/spooky
    def draw(self):
        k = self.s
        graph = self.graph
        dep = getDeps(k)

        show_sp = True

        if k.is_unary() and dep[0].sparsity() == k.sparsity():
            show_sp = False
        if k.is_binary() and dep[0].sparsity() == k.sparsity() and dep[1].sparsity() == k.sparsity():
            show_sp = False

        if show_sp:
            op = "op"
            self.drawSparsity(k, depid=op + str(k.__hash__()))
        else:
            op = ""

        if not (k.is_commutative()):
            # Non-commutative operators are represented by 'record' shapes.
            # The dependencies have different 'ports' where arrows should arrive.
            s = print_operator(self.s, ["| <f0> | ", " | <f1> |"])
            if s.startswith("(|") and s.endswith("|)"):
                s = s[2:-2]

            graph.add_node(pydot.Node(op + str(k.__hash__()), label=s, shape="Mrecord"))
            for i, n in enumerate(dep):
                graph.add_edge(pydot.Edge(str(n.__hash__()), op + str(k.__hash__()) + ":f%d" % i))
        else:
            # Commutative operators can be represented more compactly as 'oval' shapes.
            s = print_operator(k, [".", "."])
            if s.startswith("(.") and s.endswith(".)"):
                s = s[2:-2]
            if s.startswith("(") and s.endswith(")"):
                s = s[1:-1]
            self.graph.add_node(pydot.Node(op + str(k.__hash__()), label=s, shape="oval"))
            for i, n in enumerate(dep):
                self.graph.add_edge(pydot.Edge(str(n.__hash__()), op + str(k.__hash__())))