Load and return markov algorithm.
337651
def load_markov(argv, stdin):
    """"""
    if len(argv) > 3:
        with open(argv[3]) as input_file:
            return Algorithm(input_file.readlines())
    else:
        return Algorithm(stdin.readlines())
243815
def load( self, stats ):
        """"""
        rows = self.rows
        for func, raw in stats.iteritems():
            try:
                rows[func] = row = PStatRow( func,raw )
            except ValueError, err:
                log.info( 'Null row: %s', func )
        for row in rows.itervalues():
            row.weave( rows )
        return self.find_root( rows )
683614
def _load_replacement_patterns(self):
        """"""
        if self.language == 'latin':
            warnings.warn(
                        "LemmaReplacer is deprecated and will soon be removed from CLTK. Please use the BackoffLatinLemmatizer at cltk.lemmatize.latin.backoff.",
                        DeprecationWarning,
                        stacklevel=2)
            rel_path = os.path.join('~','cltk_data',
                                    self.language,
                                    'model','latin_models_cltk',
                                    'lemmata','latin_lemmata_cltk.py')
            path = os.path.expanduser(rel_path)
            #logger.info('Loading lemmata. This may take a minute.')
            loader = importlib.machinery.SourceFileLoader('latin_lemmata_cltk', path)

        elif self.language == 'greek':
            rel_path = os.path.join('~','cltk_data',
                                    self.language,
                                    'model','greek_models_cltk',
                                    'lemmata','greek_lemmata_cltk.py')
            path = os.path.expanduser(rel_path)
            #logger.info('Loading lemmata. This may take a minute.')
            loader = importlib.machinery.SourceFileLoader('greek_lemmata_cltk', path)
        module = loader.load_module()
        lemmata = module.LEMMATA
        return lemmata
1016448
def predict(self,function,args):
        """"""
        param = self.model.param_array
        fs = []
        for p in self.chain:
            self.model.param_array = p
            fs.append(function(*args))
        # reset model to starting state
        self.model.param_array = param
        return fs
363162
def load(config, opt):
        """"""
        ctx = Context(opt)
        seed_map = py_resources()
        seed_keys = sorted(set([m[0] for m in seed_map]), key=resource_sort)
        for config_key in seed_keys:
            if config_key not in config:
                continue
            for resource_config in config[config_key]:
                mod = find_model(config_key, resource_config, seed_map)
                if not mod:
                    LOG.warning("unable to find mod for %s", resource_config)
                    continue

                ctx.add(mod(resource_config, opt))

        for config_key in config.keys():
            if config_key != 'pgp_keys' and \
               config_key not in seed_keys:
                LOG.warning("missing model for %s", config_key)

        return filtered_context(ctx)
586789
def main(args=None):
    """"""

    if args is None:
        parser = get_argument_parser()
        args = parser.parse_args()

    #series_matrix_file = newstr(args.series_matrix_file, 'utf-8')
    #output_file = newstr(args.output_file, 'utf-8')
    #encoding = newstr(args.encoding, 'utf-8')
    series_matrix_file = args.series_matrix_file
    output_file = args.output_file
    encoding = args.encoding

    # log_file = args.log_file
    # quiet = args.quiet
    # verbose = args.verbose

    # logger = misc.get_logger(log_file = log_file, quiet = quiet,
    #        verbose = verbose)

    accessions, titles, celfile_urls = read_series_matrix(
        series_matrix_file, encoding=encoding)
    write_sample_sheet(output_file, accessions, titles, celfile_urls)

    return 0
1122406
def map_hmms(input_model, mapping):
    

    output_model = copy.copy(input_model)

    o_hmms = []
    for i_hmm in input_model['hmms']:
        i_hmm_name = i_hmm['name']
        o_hmm_names = mapping.get(i_hmm_name, [i_hmm_name])

        for o_hmm_name in o_hmm_names:
            o_hmm = copy.copy(i_hmm)
            o_hmm['name'] = o_hmm_name

            o_hmms.append(o_hmm)

    output_model['hmms'] = o_hmms

    return output_model
380705
def run_MDR(n,stack_float,labels=None):
    """"""
    # need to check that tmp is categorical

    x1 = stack_float.pop()
    x2 = stack_float.pop()
    # check data is categorical
    if len(np.unique(x1))<=3 and len(np.unique(x2))<=3:
        tmp = np.vstack((x1,x2)).transpose()

        if labels is None: # prediction
            return n.model.transform(tmp)[:,0]
        else: # training
            out =  n.model.fit_transform(tmp,labels)[:,0]

            return out
    else:
        return np.zeros(x1.shape[0])
1134815
def load(self):
        
        for i in range(1, self.bands + 1):
            self.__data[i - 1] = self.matrix(i)
448345
def load_repertoire(name):
    """"""
    root = os.path.abspath(os.path.dirname(__file__))
    filename = os.path.join(root, 'data', 'emd', name)

    return np.load(filename)
1316679
def load(self):
        """"""

        for drpins in self.iload(self.entry):
            self.drps[drpins.name] = drpins

        return self
812778
def execute(self, string, max_tacts=None):
        """"""
        self.init_tape(string)
        counter = 0

        while True:
            self.execute_once()
            if self.state == self.TERM_STATE:
                break
            counter += 1
            if max_tacts is not None and counter >= max_tacts:
                raise TimeoutError("algorithm hasn't been stopped")

        return self.get_tape()
1096410
def main(argv, stdin, stdout):
    """"""
    if len(argv) > 1 and argv[1:3] == ["compile", "markov"]:
        algo = load_markov(argv, stdin)
        print(algo.compile(), file=stdout)
    elif len(argv) == 4 and argv[1:3] == ["run", "markov"]:
        algo = load_markov(argv, stdin)
        for line in stdin:
            print(algo.execute(''.join(line.split())), file=stdout)

    elif len(argv) > 1 and argv[1:3] == ["compile", "turing"]:
        machine = load_turing(argv, stdin)
        print(machine.compile(), file=stdout)
    elif len(argv) == 4 and argv[1:3] == ["run", "turing"]:
        machine = load_turing(argv, stdin)
        for line in stdin:
            print(machine.execute(line), file=stdout)

    elif len(argv) == 2 and argv[1] == "test":
        path = os.path.abspath(os.path.dirname(__file__))
        argv[1] = path
        pytest.main()
    elif len(argv) == 2 and argv[1] == "version":
        print("TuringMarkov", VERSION, file=stdout)

    else:
        print(USAGE, file=stdout)
        if not (len(argv) == 2 and argv[1] == "help"):
            exit(1)
138430
def function(self,p):
        """"""
        pg = p.generator
        motion_orientation=p.orientation+pi/2.0

        new_x = p.x+p.size*pg.x
        new_y = p.y+p.size*pg.y

        image_array = pg(xdensity=p.xdensity,ydensity=p.ydensity,bounds=p.bounds,
                         x=new_x + p.speed*p.step*np.cos(motion_orientation),
                         y=new_y + p.speed*p.step*np.sin(motion_orientation),
                         orientation=p.orientation,
                         scale=pg.scale*p.scale,offset=pg.offset+p.offset)

        return image_array
918139
def main():  # suppress(unused-function)
    """"""
    description = ("""Pre-populate cache for polysquare-generic-file-linter and spellcheck-linter.""")
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument("cache_path",
                        metavar=("PATH"),
                        help="""PATH to cache""",
                        type=str)
    parser.add_argument("--technical-terms",
                        metavar=("FILE"),
                        help="""FILE containing technical terms""",
                        type=str)
    arguments = parser.parse_args(sys.argv[1:])
    valid_words_dictionary.create(arguments.cache_path)
    technical_words_dictionary.create(arguments.technical_terms,
                                      arguments.cache_path)
    return 0
918776
def run(self, data):
        
        if self.normalize_data:
            data = cell_normalize(data)
        M, W, ll = poisson_estimate_state(data, **self.params)
        outputs = []
        if self.return_w:
            outputs.append(W)
        if self.return_m:
            outputs.append(M)
        if self.return_mw:
            outputs.append(M.dot(W))
        if self.return_mds:
            X = dim_reduce(M, W, 2)
            outputs.append(X.T.dot(W))
        return outputs, ll
1287398
def adapt_entropy(line, cfg, filter_obj):
    """"""
    lines = filter_obj.filter_all(line)
    res_c = [len(set(it)) for it in lines]
    r = res_c.index(min(res_c))
    return lines[r]