Ejemplo n.º 1
0
    def test_charp_graph_networkx(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        code = """
        namespace hello
        {
            public static class world
            {
                public static double function(double x, doubly y)
                {
                    return x+y ;
                }
            }
        }
        """

        clparser, cllexer = get_parser_lexer("C#")
        parser = parse_code(code, clparser, cllexer)
        tree = parser.parse()
        st = get_tree_graph(tree, parser)

        if "travis" in sys.executable:
            # no networkx
            return

        st.draw()

        fix_tkinter_issues_virtualenv()
        import matplotlib.pyplot as plt
        if __name__ == "__main__":
            plt.show()

        plt.close('all')
Ejemplo n.º 2
0
    def test_graph_graphviz(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        code = """
        namespace hello
        {
            public static class world
            {
                public static double function(double x, doubly y)
                {
                    return x+y ;
                }
            }
        }
        """

        clparser, cllexer = get_parser_lexer("C#")
        parser = parse_code(code, clparser, cllexer)
        tree = parser.parse()
        st = get_tree_graph(tree, parser)
        dot = st.to_dot()
        # fLOG(dot)
        assert len(dot) > 0

        if "travis" not in sys.executable:
            temp = get_temp_folder(__file__, "temp_dot_grammar")
            name = os.path.join(temp, "graph.dot")
            with open(name, "w") as f:
                f.write(dot)
            img = os.path.join(temp, "graph.png")
            run_dot(name, img)
            assert os.path.exists(img)
    def test_simple_for_workflow(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        code = """
        data_a = flowdata.DataCloud ;
        modb = flowmodule.RandomFilter(
                    n= 100
                    ) ;
        connect data_a to modb.input ;

        if ( positive_number(modb.average)) {
            modc = flowmodule.Classify(model="LinearRegression") ;
            connect ( modb.data , modc.train_data ) ;

            if ( positive_number(modc.number)) {
                modc2 = flowmodule.Classify(model="SVM") ;
                connect ( modc.data , mod2.input ) ;

                for ( loopv in range(10) ) {
                    modcl = flowmodule.Classify(model=loopv) ;
                    connect ( modc2.data , modcl.output ) ;
                }

            }
        }
        """

        clparser, cllexer = get_parser_lexer("SimpleWorkflow")
        parser = parse_code(code, clparser, cllexer)
        tree = parser.parse()
        st = get_tree_string(tree, parser)
        assert len(st) > 0
        st = get_tree_graph(tree, parser)
        dot = st.to_dot()
        assert len(dot) > 0

        if "travis" not in sys.executable:
            temp = get_temp_folder(__file__, "temp_simpleworkflow_grammar_for")
            name = os.path.join(temp, "graph.dot")
            with open(name, "w") as f:
                f.write(dot)
            img = os.path.join(temp, "graph.png")
            run_dot(name, img)
            assert os.path.exists(img)