r"""
        Troubleshoot a given regular graph.
341757
def is_regular(self):
        

        """
        warn = False
        msg = 'The given matrix'

        # check symmetry
        if np.abs(self.A - self.A.T).sum() > 0:
            warn = True
            msg = '{} is not symmetric,'.format(msg)

        # check parallel edged
        if self.A.max(axis=None) > 1:
            warn = True
            msg = '{} has parallel edges,'.format(msg)

        # check that d is d-regular
        if np.min(self.d) != np.max(self.d):
            warn = True
            msg = '{} is not d-regular,'.format(msg)

        # check that g doesn't contain any self-loop
        if self.A.diagonal().any():
            warn = True
            msg = '{} has self loop.'.format(msg)

        if warn:
            self.logger.warning('{}.'.format(msg[:-1]))
603618
def _check_ising_quadratic_ranges(quad_ranges, graph):
        """"""
        if quad_ranges is None:
            quad_ranges = {}

        # first just populate the top level so we can rely on the structure
        for u in graph:
            if u not in quad_ranges:
                quad_ranges[u] = {}

        # next let's propgate and check what is already present
        for u, neighbors in iteritems(quad_ranges):
            for v, rang in iteritems(neighbors):
                # check the range
                rang = Specification._check_range(rang)

                if u in quad_ranges[v]:
                    # it's symmetric
                    if quad_ranges[u][v] != quad_ranges[v][u]:
                        raise ValueError("mismatched ranges for ising_quadratic_ranges")
                quad_ranges[v][u] = quad_ranges[u][v] = rang

        # finally fill in the missing stuff
        for u, v in graph.edges:
            if u not in quad_ranges[v]:
                quad_ranges[u][v] = quad_ranges[v][u] = [-1, 1]

        return quad_ranges
1017613
def graph_type(self, graph):
        """"""
        graph = self.pack(graph)
        return self.sql('graph_type', graph).fetchone()[0]
472703
def validate_basic_smoother():
    """"""
    x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
    plt.figure()
    # plt.plot(x, y, '.', label='Data')
    for span in smoother.DEFAULT_SPANS:
        my_smoother = smoother.perform_smooth(x, y, span)
        friedman_smooth, _resids = run_friedman_smooth(x, y, span)
        plt.plot(x, my_smoother.smooth_result, '.-', label='pyace span = {0}'.format(span))
        plt.plot(x, friedman_smooth, '.-', label='Friedman span = {0}'.format(span))
    finish_plot()
1030906
def validate_basic_smoother_resid():
    """"""
    x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
    plt.figure()
    for span in smoother.DEFAULT_SPANS:
        my_smoother = smoother.perform_smooth(x, y, span)
        _friedman_smooth, resids = run_friedman_smooth(x, y, span)  # pylint: disable=unused-variable
        plt.plot(x, my_smoother.cross_validated_residual, '.-',
                 label='pyace span = {0}'.format(span))
        plt.plot(x, resids, '.-', label='Friedman span = {0}'.format(span))
    finish_plot()
535128
def sg_graph_input(self, value, stream_id):
        """""""

        self.sensor_graph.process_input(stream_id, value)
        return [Error.NO_ERROR]
1163015
def find_gt(a, x):
    """"""
    i = bs.bisect_right(a, x)
    if i != len(a): return i
    raise ValueError
1307189
def validate(self, graph=None):
        
        graph = graph if graph is not None else self.graph
        if len(self.ind_nodes(graph)) == 0:
            return (False, 'no independent nodes detected')
        try:
            self.topological_sort(graph)
        except ValueError:
            return (False, 'failed topological sort')
        return (True, 'valid')
255762
def graphs(self):
        """"""
        result = Dummy()
        for graph in graphs.__all__:
            cls = getattr(graphs, graph)
            setattr(result, cls.short_name, cls(self))
        return result
905691
def fixpix(data, mask, kind='linear'):
    """"""
    if data.shape != mask.shape:
        raise ValueError

    if not numpy.any(mask):
        return data

    x = numpy.arange(0, data.shape[0])
    for row, mrow in zip(data, mask):
        if numpy.any(mrow):  # Interpolate if there's some pixel missing
            valid = (mrow == numpy.False_)
            invalid = (mrow == numpy.True_)
            itp = interp1d(x[valid], row[valid], kind=kind, copy=False)
            row[invalid] = itp(x[invalid]).astype(row.dtype)
    return data
133004
private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph)
    {
        CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph);

        if (cycleDetector.detectCycles())
        {
            // if we have cycles, then try to throw an exception with some usable data
            Set<RuleProvider> cycles = cycleDetector.findCycles();
            StringBuilder errorSB = new StringBuilder();
            for (RuleProvider cycle : cycles)
            {
                errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator());
                Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle);
                for (RuleProvider subCycle : subCycleSet)
                {
                    errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator());
                }
            }
            throw new RuntimeException("Dependency cycles detected: " + errorSB.toString());
        }
    }
34240
def _to_graph(self, contexts):
        """"""
        prev = None

        for context in contexts:
            if prev is None:
                prev = context
                continue

            yield prev[0], context[1], context[0]
            prev = context
177670
def missing_nodes(self):
        """"""
        missing = set()
        for target_addr, target_attrs in self.graph.node.items():
            if 'target_obj' not in target_attrs:
                missing.add(target_addr)
        return missing
957611
def main(argv=None):
  """"""
  report_paths = argv[1:]

  fail_names = FLAGS.fail_names.split(',')

  for report_path in report_paths:
    plot_report_from_path(report_path, label=report_path, fail_names=fail_names)
  pyplot.legend()

  pyplot.xlim(-.01, 1.)
  pyplot.ylim(0., 1.)

  pyplot.show()
929767
def evaluate(self, x):
        """"""

        if not hasattr(self, '_coefficients'):
            # Graph Fourier transform -> modulation -> inverse GFT.
            c = self.G.igft(self._kernels.evaluate(self.G.e).squeeze())
            c = np.sqrt(self.G.n_vertices) * self.G.U * c[:, np.newaxis]
            self._coefficients = self.G.gft(c)

        shape = x.shape
        x = x.flatten()
        y = np.full((self.n_features_out, x.size), np.nan)
        for i in range(len(x)):
            query = self._coefficients[x[i] == self.G.e]
            if len(query) != 0:
                y[:, i] = query[0]
        return y.reshape((self.n_features_out,) + shape)
567697
def process_input_graph(func):
    """"""
    @wraps(func)
    def wrapped_func(*args, **kwargs):
        input_graph = args[0]
        if isinstance(input_graph, nx.DiGraph):
            return func(*args, **kwargs)
        else:
            nx_graph = dict_to_nx(args[0], oriented=True)
            args = [nx_graph] + list(args[1:])
            return func(*args, **kwargs)
    return wrapped_func
380492
def solve_ifelse(expr, vars):
    """"""
    for condition, result in expr.conditions():
        if boolean.asbool(solve(condition, vars).value):
            return solve(result, vars)

    return solve(expr.default(), vars)