Get rid of fake returns (i.e., Ijk_FakeRet edges) from this CFG

        :return: None
183533
def remove_fakerets(self):
        
        fakeret_edges = [ (src, dst) for src, dst, data in self.graph.edges(data=True)
                         if data['jumpkind'] == 'Ijk_FakeRet' ]
        self.graph.remove_edges_from(fakeret_edges)
1173617
def edges_dump(self):
        """"""
        self._flush_edges()
        for (
                graph, orig, dest, idx, branch, turn, tick, extant
        ) in self.sql('edges_dump'):
            yield (
                self.unpack(graph),
                self.unpack(orig),
                self.unpack(dest),
                idx,
                branch,
                turn,
                tick,
                bool(extant)
            )
536510
def strip_line_magic_v3(cls,line):
        """"""

        matches = re.findall("run_line_magic\(([^]]+)", line)
        if matches and matches[0]: # This line contains the pattern
            match = matches[0]
            if match[-1] == ')':
                match = match[:-1] # Just because the re way is hard
            magic_kind,stripped = eval(match)
        else:
            stripped = line
            magic_kind = ""
        return stripped,magic_kind
842648
def destroy
      return unless Feature.bfd_enabled?
      [:interval,
       :ipv4_interval,
       :ipv6_interval,
       :fabricpath_interval,
       :echo_interface,
       :echo_rx_interval,
       :ipv4_echo_rx_interval,
       :ipv6_echo_rx_interval,
       :fabricpath_vlan,
       :slow_timer,
       :ipv4_slow_timer,
       :ipv6_slow_timer,
       :fabricpath_slow_timer,
       :startup_timer,
      ].each do |prop|
        send("#{prop}=", send("default_#{prop}")) if
          send prop
      end
      set_args_keys_default
    end
1309932
def _prune_edges(G, X, traj_lengths, pruning_thresh=0.1, verbose=False):
  ''''''
  W = G.matrix('dense', copy=True)
  degree = G.degree(kind='out', weighted=False)
  i = 0
  num_bad = 0
  for n in traj_lengths:
    s, t = np.nonzero(W[i:i+n-1])
    graph_edges = X[t] - X[s+i]
    traj_edges = np.diff(X[i:i+n], axis=0)
    traj_edges = np.repeat(traj_edges, degree[i:i+n-1], axis=0)
    theta = paired_distances(graph_edges, traj_edges, 'cosine')
    bad_edges = theta > pruning_thresh
    s, t = s[bad_edges], t[bad_edges]
    if verbose:  # pragma: no cover
      num_bad += np.count_nonzero(W[s,t])
    W[s,t] = 0
    i += n
  if verbose:  # pragma: no cover
    print('removed %d bad edges' % num_bad)
  return Graph.from_adj_matrix(W)
1359952
def fake(args):
    
    from math import ceil
    from random import choice

    from Bio import SeqIO
    from Bio.Seq import Seq
    from Bio.SeqRecord import SeqRecord

    p = OptionParser(fake.__doc__)
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    inputbed, = args
    bed = Bed(inputbed)
    recs = []
    for seqid, sb in bed.sub_beds():
        maxend = max(x.end for x in sb)
        size = int(ceil(maxend / 1000.) * 1000)
        seq = "".join([choice("ACGT") for x in xrange(size)])
        rec = SeqRecord(Seq(seq), id=seqid, description="")
        recs.append(rec)

    fw = must_open(opts.outfile, "w")
    SeqIO.write(recs, fw, "fasta")
449460
static Matcher removeFalseBranchesFromOr(Matcher matcher) {
    if (matcher instanceof OrMatcher) {
      List<Matcher> ms = matcher.<OrMatcher>as()
          .matchers()
          .stream()
          .filter(m -> !(m instanceof FalseMatcher))
          .collect(Collectors.toList());
      return OrMatcher.create(ms);
    }
    return matcher;
  }
727623
def do_fake_filter( formatter, arg=None ):
    
    args = []
    if not arg is None: args.append(arg)
    return Faker.getGenerator().format( formatter, *args )
885177
def neg(self):
        

        si = StridedInterval(bits=self.bits, stride=0, lower_bound=0, upper_bound=0).sub(self)
        si.uninitialized = self.uninitialized
        return si
1082492
def __deprecate_defaults(
        self,
        new_func: str,
        bg_blend: Any,
        alignment: Any = ...,
        clear: Any = ...,
    ) -> None:
        
        if not __debug__:
            return

        fg = self.default_fg  # type: Any
        bg = self.default_bg  # type: Any
        if bg_blend == tcod.constants.BKGND_NONE:
            bg = None
        if bg_blend == tcod.constants.BKGND_DEFAULT:
            bg_blend = self.default_bg_blend
        else:
            bg_blend = None
        if bg_blend == tcod.constants.BKGND_NONE:
            bg = None
            bg_blend = None
        if bg_blend == tcod.constants.BKGND_SET:
            bg_blend = None
        if alignment is None:
            alignment = self.default_alignment
            if alignment == tcod.constants.LEFT:
                alignment = None
        else:
            alignment = None
        if clear is not ...:
            fg = None
        params = []
        if clear is True:
            params.append('ch=ord(" ")')
        if clear is False:
            params.append("ch=0")
        if fg is not None:
            params.append("fg=%s" % (fg,))
        if bg is not None:
            params.append("bg=%s" % (bg,))
        if bg_blend is not None:
            params.append("bg_blend=%s" % (self.__BG_BLEND_LOOKUP[bg_blend],))
        if alignment is not None:
            params.append(
                "alignment=%s" % (self.__ALIGNMENT_LOOKUP[alignment],)
            )
        param_str = ", ".join(params)
        if not param_str:
            param_str = "."
        else:
            param_str = " and add the following parameters:\n%s" % (param_str,)
        warnings.warn(
            "Console functions using default values have been deprecated.\n"
            "Replace this method with `Console.%s`%s" % (new_func, param_str),
            DeprecationWarning,
            stacklevel=3,
        )
317554
def obfuscate_function(tokens, index, replace, replacement, *args):
    
    def return_replacement(replacement):
        FUNC_REPLACEMENTS[replacement] = replace
        return replacement
    tok = tokens[index]
    token_type = tok[0]
    token_string = tok[1]
    prev_tok = tokens[index-1]
    prev_tok_string = prev_tok[1]
    if token_type != tokenize.NAME:
        return None # Skip this token
    if token_string.startswith('__'):
        return None
    if token_string == replace:
        if prev_tok_string != '.':
            if token_string == replace:
                return return_replacement(replacement)
        else:
            parent_name = tokens[index-2][1]
            if parent_name in CLASS_REPLACEMENTS:
                # This should work for @classmethod methods
                return return_replacement(replacement)
            elif parent_name in VAR_REPLACEMENTS:
                # This covers regular ol' instance methods
                return return_replacement(replacement)
274059
def fCZ_std_errs(self):
        
        return {tuple(es.targets): es.fCZ_std_err for es in self.edges_specs}
1310406
private int removeExplicitCodes() {
        int w = 0;
        for (int i = 0; i < textLength; ++i) {
            byte t = initialTypes[i];
            if (!(t == LRE || t == RLE || t == LRO || t == RLO || t == PDF || t == BN)) {
                embeddings[w] = embeddings[i];
                resultTypes[w] = resultTypes[i];
                resultLevels[w] = resultLevels[i];
                w++;
            }
        }
        return w; // new textLength while explicit levels are removed
    }
309807
def _remove_edge(im, r):
    
    '''
    edge = sp.ones_like(im)
    if len(im.shape) == 2:
        sx, sy = im.shape
        edge[r:sx-r, r:sy-r] = im[r:sx-r, r:sy-r]
    else:
        sx, sy, sz = im.shape
        edge[r:sx-r, r:sy-r, r:sz-r] = im[r:sx-r, r:sy-r, r:sz-r]
    return edge
545094
def prune(args):
    
    from collections import defaultdict

    p = OptionParser(prune.__doc__)
    add_graph_options(p)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    bestedges, = args
    G = read_graph(bestedges, maxerr=opts.maxerr)
    reads_to_ctgs = parse_ctgs(bestedges, opts.frgctg)
    edges = defaultdict(int)
    r = defaultdict(int)
    for a, b, d in G.edges_iter(data=True):
        ua, ub = reads_to_ctgs.get(a), reads_to_ctgs.get(b)
        nn = (ua, ub).count(None)
        if nn == 0:
            if ua == ub:
                r["Same tigs"] += 1
            else:
                r["Diff tigs"] += 1
                if ua > ub:
                    ua, ub = ub, ua
                edges[(ua, ub)] += 1
        elif nn == 1:
            r["One null"] += 1
        else:
            assert nn == 2
            r["Two nulls"] += 1

    U = nx.Graph()
    difftigs = "diff_tigs.txt"
    neighbors = defaultdict(list)
    fw = open(difftigs, "w")
    for (ua, ub), count in edges.items():
        print("\t".join((ua, ub, str(count))), file=fw)
        U.add_edge(ua, ub, weight=count)
        neighbors[ua].append((ub, count))
        neighbors[ub].append((ua, count))
    fw.close()

    print("[Unitig edge property]", file=sys.stderr)
    for k, v in r.items():
        print(": ".join((k, str(v))), file=sys.stderr)
    print("Total: {0}".format(sum(r.values())), file=sys.stderr)

    print("[Unitig degree distribution]", file=sys.stderr)
    degrees = U.degree()
    degree_counter = Counter(degrees.values())
    for degree, count in sorted(degree_counter.items()):
        print("{0}\t{1}".format(degree, count), file=sys.stderr)

    # To find associative contigs, one look for a contig that is connected and
    # only connected to another single contig - and do that recursively until no
    # more contigs can be found
    associative = {}
    for ua, ubs in neighbors.items():
        if len(ubs) == 1:   # Only one neighbor
            ub, count = ubs[0]
            if count >= 2:  # Bubble
                associative[ua] = (ub, count)
    print("A total of {0} associative contigs found"\
                        .format(len(associative)), file=sys.stderr)

    # Keep only one for mutual associative
    for ua, ub in associative.items():
        if ub in associative and ua < ub:
            print(ua, "mutually associative with", ub, file=sys.stderr)
            del associative[ub]
    print("A total of {0} associative contigs retained"\
                        .format(len(associative)), file=sys.stderr)

    assids = "associative.ids"
    fw = open(assids, "w")
    for ua, (ub, count) in sorted(associative.items(), key=lambda x:(x[1], x[0])):
        print("\t".join((ua, ub, str(count))), file=fw)
    fw.close()
    logging.debug("Associative contigs written to `{0}`".format(assids))
834739
def remove_ctx(properties):
    
    result = {}

    for name in properties:
        elt_properties = properties[name]
        result[name] = []
        for _, value in elt_properties:
            result[name].append(value)

    return result
326091
def strip_line_magic_v2(cls,line):
        """"""

        matches = re.findall("magic\(([^]]+)", line)
        if matches and matches[0]: # This line contains the pattern
            match = matches[0]
            if match[-1] == ')':
                match = match[:-1] # Just because the re way is hard
            stripped = eval(match)
            magic_kind = stripped.split(' ')[0]
            if len(stripped.split(' '))>1:
                stripped = stripped.split(' ')[1:]
            else:
                stripped = ""
        else:
            stripped = line
            magic_kind = ""
        return stripped,magic_kind