Handles the make-graph-file subcommand
345052
def _bsecurate_cli_make_graph_file(args):
    ''''''

    curate.make_graph_file(args.basis, args.outfile, args.render, args.version, args.data_dir)
    return ''
1132874
def parser(input_args=None):
    

    parser = argparse.ArgumentParser(
        description="sick, the spectroscopic inference crank", epilog="Use "
            "'sick-model COMMAND -h' for information on a specific command."
            " Documentation and examples available at "
            "https://github.com/andycasey/sick")

    # Create a parent subparser.
    parent_parser = argparse.ArgumentParser(add_help=False)
    parent_parser.add_argument(
        "-v", "--verbose", dest="verbose", action="store_true", default=False,
        help="Vebose logging mode.")
    parent_parser.add_argument(
        "--clobber", dest="clobber", action="store_true", default=False, 
        help="Overwrite existing files if they already exist.")
    parent_parser.add_argument(
        "--debug", dest="debug", action="store_true", default=False,
        help="Enable debug mode. Any suppressed exception will be re-raised.")
    parent_parser.add_argument(
        "-o", "--output_dir", dest="output_dir", nargs="?", type=str,
        help="Directory for the files that will be created. If not given, this"
        " defaults to the current working directory.", default=os.getcwd())

    # Create subparsers.
    subparsers = parser.add_subparsers(title="command", dest="command",
        description="Specify the action to perform.")

    # Create parser for the aggregate command
    aggregate_parser = subparsers.add_parser(
        "aggregate", parents=[parent_parser],
        help="Aggregate many result files into a single tabular FITS file.")
    aggregate_parser.add_argument("output_filename", type=str, nargs=1,
        help="Output filename to aggregate results into.")
    aggregate_parser.add_argument("result_filenames", nargs="+",
        help="The YAML result filenames to combine.")
    aggregate_parser.set_defaults(func=aggregate)

    # Create parser for the estimate command
    estimate_parser = subparsers.add_parser(
        "estimate", parents=[parent_parser],
        help="Compute a point estimate of the model parameters given the data.")
    estimate_parser.add_argument(
        "model", type=str,
        help="The model filename in YAML-style formatting.")
    estimate_parser.add_argument(
        "spectrum_filenames", nargs="+",
        help="Filenames of (observed) spectroscopic data.")
    estimate_parser.add_argument(
        "--filename-prefix", "-p", dest="filename_prefix",
        type=str, help="The filename prefix to use for the output files.")
    estimate_parser.add_argument(
        "--no-plots", dest="plotting", action="store_false", default=True,
        help="Disable plotting.")
    estimate_parser.add_argument(
        "--plot-format", "-pf", dest="plot_format", action="store", type=str, 
        default="png", help="Format for output plots (default: %(default)s)")
    estimate_parser.add_argument(
        "-r", dest="read_from_filename", action="store", type=bool,
        default=False, help="Read spectrum paths from a filename.")
    estimate_parser.set_defaults(func=estimate)

    # Create parser for the optimise command
    optimise_parser = subparsers.add_parser(
        "optimise", parents=[parent_parser],
        help="Optimise the model parameters, given the data.")
    optimise_parser.add_argument(
        "model", type=str,
        help="The model filename in YAML-style formatting.")
    optimise_parser.add_argument(
        "spectrum_filenames", nargs="+",
        help="Filenames of (observed) spectroscopic data.")
    optimise_parser.add_argument(
        "--filename-prefix", "-p", dest="filename_prefix", type=str,
        help="The filename prefix to use for the output files.")
    optimise_parser.add_argument(
        "--no-plots", dest="plotting", action="store_false", default=True,
        help="Disable plotting.")
    optimise_parser.add_argument(
        "--plot-format", "-pf", dest="plot_format", action="store", type=str,
        default="png", help="Format for output plots (default: %(default)s)")
    optimise_parser.add_argument(
        "-r", dest="read_from_filename", action="store", type=bool,
        default=False, help="Read spectrum paths from a filename.")
    optimise_parser.set_defaults(func=optimise)

    # Create parser for the infer command
    infer_parser = subparsers.add_parser(
        "infer", parents=[parent_parser],
        help="Infer the model parameters, given the data.")
    infer_parser.add_argument(
        "model", type=str,
        help="The model filename in YAML-style formatting.")
    infer_parser.add_argument(
        "spectrum_filenames", nargs="+",
        help="Filenames of (observed) spectroscopic data.")
    infer_parser.add_argument(
        "--filename-prefix", "-p", dest="filename_prefix", type=str,
        help="The filename prefix to use for the output files.")
    infer_parser.add_argument(
        "--no-chains", dest="save_chain_files", action="store_false",
        default=True, help="Do not save the chains to disk.", )
    infer_parser.add_argument(
        "--no-plots", dest="plotting", action="store_false", default=True,
        help="Disable plotting.")
    infer_parser.add_argument(
        "--plot-format", "-pf", dest="plot_format", action="store", type=str,
        default="png", help="Format for output plots (default: %(default)s)")
    infer_parser.add_argument(
        "-r", dest="read_from_filename", action="store", type=bool,
        default=False, help="Read spectrum paths from a filename.")
    infer_parser.set_defaults(func=infer)

    args = parser.parse_args(input_args)
    logger.setLevel(logging.DEBUG if args.verbose else logging.INFO)

    # Check plot formats.
    if args.command.lower() in ("estimate", "optimise", "infer") \
    and args.plotting:

        import matplotlib.pyplot as plt
        fig = plt.figure()
        available = fig.canvas.get_supported_filetypes().keys()
        plt.close(fig)

        if args.plot_format.lower() not in available:
            raise ValueError("plotting format {0} is unavailable: Options are:"\
                " {1}".format(args.plot_format.lower(), ", ".join(available)))

    # Create a default filename prefix based on the input filename arguments
    if args.command.lower() in ("estimate", "optimise", "infer") \
    and args.filename_prefix is None \
    and not args.read_from_filename:
        args.filename_prefix = _default_output_prefix(args.spectrum_filenames)

        handler = logging.FileHandler("{}.log".format(
            os.path.join(args.output_dir, args.filename_prefix)))
        formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    else:
        args.filename_prefix = ""

    return args
255442
def graphviz(self, directory, **kwargs):
        ""
        import os
        if not os.path.isdir(directory):
            os.mkdir(directory)
        output = os.path.join(directory, 'evodag-%s')
        for k, m in enumerate(self.models):
            m.graphviz(output % k, **kwargs)
297977
def main(graph):
    
    args = parse_args(graph)

    if args.drop:
        drop_all(graph)
    create_all(graph)
472535
public void setGraphvizCommand(String cmd) {
		if (cmd != null && cmd.length() == 0)
			cmd = null;
		graphvizCommand = cmd;
	}
765279
def add_file_recursive(self, filename, trim=False):
        

        assert not self.final, 'Trying to mutate a final graph.'
        self.add_source_file(filename)
        queue = collections.deque([filename])
        seen = set()
        while queue:
            filename = queue.popleft()
            self.graph.add_node(filename)
            try:
                deps, broken = self.get_file_deps(filename)
            except parsepy.ParseError:
                # Python couldn't parse `filename`. If we're sure that it is a
                # Python file, we mark it as unreadable and keep the node in the
                # graph so importlab's callers can do their own syntax error
                # handling if desired.
                if filename.endswith('.py'):
                    self.unreadable_files.add(filename)
                else:
                    self.graph.remove_node(filename)
                continue
            for f in broken:
                self.broken_deps[filename].add(f)
            for f in deps:
                if self.follow_file(f, seen, trim):
                    queue.append(f)
                    seen.add(f)
                self.graph.add_node(f)
                self.graph.add_edge(filename, f)
691941
def cli(*args, **kwargs):
    
    # Convert CSV file
    content = convert.convert(kwargs["input_file"], **kwargs)

    # Serve the temporary file in browser.
    if kwargs["serve"]:
        convert.serve(content)
    # Write to output file
    elif kwargs["output_file"]:
        # Check if file can be overwrite
        if (not kwargs["overwrite"] and
                not prompt_overwrite(kwargs["output_file"])):
            raise click.Abort()

        convert.save(kwargs["output_file"], content)
        click.secho("File converted successfully: {}".format(
            kwargs["output_file"]), fg="green")
    else:
        # If its not server and output file is missing then raise error
        raise click.BadOptionUsage("Missing argument \"output_file\".")
1350850
def save_graph(graphdef):
    ''''''
    if graphdef.filename is None:
        if 'HOME' in os.environ:
            dname = os.path.join(os.environ['HOME'], '.mavproxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        elif 'LOCALAPPDATA' in os.environ:
            dname = os.path.join(os.environ['LOCALAPPDATA'], 'MAVProxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        else:
            graphdef.filename = 'mavgraphs.xml'
    if graphdef.filename is None:
        print("No file to save graph to")
        return
    try:
        graphs = load_graph_xml(open(graphdef.filename).read(), graphdef.filename, load_all=True)
    except Exception:
        graphs = []
    found_name = False
    for i in range(len(graphs)):
        if graphs[i].name == graphdef.name:
            graphs[i] = graphdef
            found_name = True
            break
    if not found_name:
        graphs.append(graphdef)
    pipe_console_input.send("Saving %u graphs to %s" % (len(graphs), graphdef.filename))
    f = open(graphdef.filename, "w")
    f.write("<graphs>\n\n")
    for g in graphs:
        f.write(" <graph name='%s'>\n" % g.name.strip())
        if g.description is None:
            g.description = ''
        f.write("  <description>%s</description>\n" % g.description.strip())
        for e in g.expressions:
            f.write("  <expression>%s</expression>\n" % e.strip())
        f.write(" </graph>\n\n")
    f.write("</graphs>\n")
    f.close()
614400
def write_graph(self, filename):
        
        f = open(filename, 'w')
        f.write(self._get_graphviz_data())
        f.close()
169939
def output_files(self):
        
        for dep in self.subgraph.successors(self.address):
            dep_rule = self.subgraph.node[dep]['target_obj']
            for dep_file in dep_rule.output_files:
                yield self.translate_path(dep_file, dep_rule).lstrip('/')
605721
def prepare_plot_data(data_file):
    

    G = ig.Graph.Read_GML(data_file)

    layout = G.layout('graphopt')
    labels = list(G.vs['label'])

    N = len(labels)
    E = [e.tuple for e in G.es]

    community = G.community_multilevel().membership
    communities = len(set(community))

    color_list = community_colors(communities)

    Xn = [layout[k][0] for k in range(N)]
    Yn = [layout[k][1] for k in range(N)]

    Xe = []
    Ye = []

    for e in E:
        Xe += [layout[e[0]][0], layout[e[1]][0], None]
        Ye += [layout[e[0]][1], layout[e[1]][1], None]

    lines = Scatter(x=Xe,
                    y=Ye,
                    mode='lines',
                    line=Line(color='rgb(210,210,210)', width=1),
                    hoverinfo='none'
                    )
    plot_data = [lines]

    node_x = [[] for i in range(communities)]
    node_y = [[] for i in range(communities)]
    node_labels = [[] for i in range(communities)]

    for j in range(len(community)):
        index = community[j]

        node_x[index].append(layout[j][0])
        node_y[index].append(layout[j][1])
        node_labels[index].append(labels[j])

    for i in range(communities):
        trace = Scatter(x=node_x[i],
                        y=node_y[i],
                        mode='markers',
                        name='ntw',
                        marker=Marker(symbol='dot',
                                      size=5,
                                      color=color_list[i],
                                      line=Line(
                                          color='rgb(50,50,50)', width=0.5)
                                      ),
                        text=node_labels[i],
                        hoverinfo='text'
                        )

        plot_data.append(trace)

    return plot_data
831327
def load_graphs():
    ''''''
    mestate.graphs = []
    gfiles = ['mavgraphs.xml']
    if 'HOME' in os.environ:
        for dirname, dirnames, filenames in os.walk(os.path.join(os.environ['HOME'], ".mavproxy")):
            for filename in filenames:
                
                if filename.lower().endswith('.xml'):
                    gfiles.append(os.path.join(dirname, filename))
    for file in gfiles:
        if not os.path.exists(file):
            continue
        graphs = load_graph_xml(open(file).read(), file)
        if graphs:
            mestate.graphs.extend(graphs)
            mestate.console.writeln("Loaded %s" % file)
    # also load the built in graphs
    dlist = pkg_resources.resource_listdir("MAVProxy", "tools/graphs")
    for f in dlist:
        raw = pkg_resources.resource_stream("MAVProxy", "tools/graphs/%s" % f).read()
        graphs = load_graph_xml(raw, None)
        if graphs:
            mestate.graphs.extend(graphs)
            mestate.console.writeln("Loaded %s" % f)
    mestate.graphs = sorted(mestate.graphs, key=lambda g: g.name)
1152005
def _build_graph_run(self, run_args):
    """"""
    # Could try to use tfe.py_func(fct) but this would require knowing
    # information about the signature of the function.

    # Create a new graph:
    with tf.Graph().as_default() as g:
      # Create placeholder
      input_ = run_args.input
      placeholder = tf.compat.v1.placeholder(
          dtype=input_.dtype, shape=input_.shape)
      output = run_args.fct(placeholder)
    return GraphRun(
        session=raw_nogpu_session(g),
        graph=g,
        placeholder=placeholder,
        output=output,
    )
925331
def cli():
    
    import argparse

    parser = argparse.ArgumentParser(description='Send data to graphite')

    # Core of the application is to accept a metric and a value.
    parser.add_argument('metric', metavar='metric', type=str,
                        help='name.of.metric')
    parser.add_argument('value', metavar='value', type=int,
                        help='value of metric as int')

    args = parser.parse_args()
    metric = args.metric
    value = args.value

    graphitesend_instance = init()
    graphitesend_instance.send(metric, value)
777433
def compile(manager, path, allow_naked_names, allow_nested, disallow_unqualified_translocations,
            no_identifier_validation, no_citation_clearing, required_annotations, skip_tqdm, verbose):
    """"""
    if verbose:
        logging.basicConfig(level=logging.DEBUG)
        log.setLevel(logging.DEBUG)
        log.debug('using connection: %s', manager.engine.url)

    click.secho('Compilation', fg='red', bold=True)
    if skip_tqdm:
        click.echo('```')
    graph = from_path(
        path,
        manager=manager,
        use_tqdm=(not (skip_tqdm or verbose)),
        allow_nested=allow_nested,
        allow_naked_names=allow_naked_names,
        disallow_unqualified_translocations=disallow_unqualified_translocations,
        citation_clearing=(not no_citation_clearing),
        required_annotations=required_annotations,
        no_identifier_validation=no_identifier_validation,
        allow_definition_failures=True,
    )
    if skip_tqdm:
        click.echo('```')
    to_pickle(graph, get_corresponding_pickle_path(path))

    click.echo('')
    _print_summary(graph, ticks=skip_tqdm)

    sys.exit(0 if 0 == graph.number_of_warnings() else 1)
1002711
def tool(_progname=sys.argv[0],
         _argv=sys.argv[1:],
         _syspath=sys.path,
         _findMachines=findMachines,
         _print=print):
    

    DESCRIPTION = """
    Visualize automat.MethodicalMachines as graphviz graphs.
    """
    EPILOG = """
    You must have the graphviz tool suite installed.  Please visit
    http://www.graphviz.org for more information.
    """
    if _syspath[0]:
        _syspath.insert(0, '')
    argumentParser = argparse.ArgumentParser(
        prog=_progname,
        description=DESCRIPTION,
        epilog=EPILOG)
    argumentParser.add_argument('fqpn',
                                help="A Fully Qualified Path name"
                                " representing where to find machines.")
    argumentParser.add_argument('--quiet', '-q',
                                help="suppress output",
                                default=False,
                                action="store_true")
    argumentParser.add_argument('--dot-directory', '-d',
                                help="Where to write out .dot files.",
                                default=".automat_visualize")
    argumentParser.add_argument('--image-directory', '-i',
                                help="Where to write out image files.",
                                default=".automat_visualize")
    argumentParser.add_argument('--image-type', '-t',
                                help="The image format.",
                                choices=graphviz.FORMATS,
                                default='png')
    argumentParser.add_argument('--view', '-v',
                                help="View rendered graphs with"
                                " default image viewer",
                                default=False,
                                action="store_true")
    args = argumentParser.parse_args(_argv)

    explicitlySaveDot = (args.dot_directory
                         and (not args.image_directory
                              or args.image_directory != args.dot_directory))
    if args.quiet:
        def _print(*args):
            pass

    for fqpn, machine in _findMachines(args.fqpn):
        _print(fqpn, '...discovered')

        digraph = machine.asDigraph()

        if explicitlySaveDot:
            digraph.save(filename="{}.dot".format(fqpn),
                         directory=args.dot_directory)
            _print(fqpn, "...wrote dot into", args.dot_directory)

        if args.image_directory:
            deleteDot = not args.dot_directory or explicitlySaveDot
            digraph.format = args.image_type
            digraph.render(filename="{}.dot".format(fqpn),
                           directory=args.image_directory,
                           view=args.view,
                           cleanup=deleteDot)
            if deleteDot:
                msg = "...wrote image into"
            else:
                msg = "...wrote image and dot into"
            _print(fqpn, msg, args.image_directory)
290784
def do_graphviz(self, args, arguments):
        
        filename = arguments['FILENAME']
        if platform.system() == 'Darwin':
            if os.path.isfile(filename):
                os.system("open -a '\''/Applications/Graphviz.app'\'' " + filename)