コード例 #1
0
    def _simul_coloring(prob):
        if options.outfile is None:
            outfile = sys.stdout
        else:
            outfile = open(options.outfile, 'w')
        if prob.model._use_derivatives:
            Problem._post_setup_func = None  # avoid recursive loop

            with profiling('coloring_profile.out'
                           ) if options.profile else do_nothing_context():
                color_info = get_simul_meta(
                    prob,
                    repeats=options.num_jacs,
                    tol=options.tolerance,
                    show_jac=options.show_jac,
                    include_sparsity=not options.no_sparsity,
                    setup=False,
                    run_model=True,
                    stream=outfile)

            if sys.stdout.isatty():
                simul_coloring_summary(color_info, stream=sys.stdout)
        else:
            print(
                "Derivatives are turned off.  Cannot compute simul coloring.")
        exit()
コード例 #2
0
ファイル: cprof.py プロジェクト: naylor-b/om_devtools
def _cprof_exec(options, user_args):
    """
    Gather profiling info.

    Parameters
    ----------
    options : argparse Namespace
        Command line options.
    user_args : list of str
        Args to be passed to the user script.
    """
    with profiling(options.outfile):
        _load_and_exec(options.file[0], user_args)
コード例 #3
0
ファイル: coloring.py プロジェクト: OpenMDAO/OpenMDAO
    def _simul_coloring(prob):
        if options.outfile is None:
            outfile = sys.stdout
        else:
            outfile = open(options.outfile, 'w')
        if prob.model._use_derivatives:
            Problem._post_setup_func = None  # avoid recursive loop

            with profiling('coloring_profile.out') if options.profile else do_nothing_context():
                color_info = get_simul_meta(prob,
                                            repeats=options.num_jacs, tol=options.tolerance,
                                            show_jac=options.show_jac,
                                            include_sparsity=not options.no_sparsity,
                                            setup=False, run_model=True,
                                            stream=outfile)

            if sys.stdout.isatty():
                simul_coloring_summary(color_info, stream=sys.stdout)
        else:
            print("Derivatives are turned off.  Cannot compute simul coloring.")
        exit()