def add_second_info(info): if info['distiller_info'].get('requires_bow', False): second_info = {'data_name': info['data_name']} iterate(['token:BC', 'vocab', 'vector:B'], lambda second_info: run_distiller_on(info, second_info), info=second_info, print_iterates=False) else: run_distiller_on(info, None)
def run_tokenizer(info=None): nbprint('Tokenizer').push() if info is None: iterate(['token:BC', 'data'], tokenize) else: tokenize(info) nbprint.pop()
def run_importer(info=None): nbprint('Importer').push() if info is None: iterate(["data"], [import_data], depth=0) else: import_data(info) nbprint.pop()
def run_vocab(info=None): nbprint('Vocab').push() if info is None: iterate(["data", "token", "vocab"], [check_tokens, build_vocab]) else: check_tokens(info) build_vocab(info) nbprint.pop()
def run_distiller(): global rejector rejector = Rejector(0.99) nbprint('Distiller').push() iterate(['distiller', 'distillerinputs'], add_second_info, print_iterates=False) nbprint.pop()
def step(self, n=1, random=False) -> 'State': if bool(self['winner']): return self board = self.board # Update Board n times for i in range(n): winner = util.check_win(board) if bool(winner): return self.using( winner=winner ) if random: board = util.random_move(board) board = util.iterate(board) # set active player based on iteration count activePlayer = self.nextPlayer if n % 2 == 1 else self.activePlayer # # Increase round if needed (every other step) # round = self['round'] # if self.activePlayer == 2: # round += 1 return self.using( board=board, activePlayer=activePlayer, # round=round, )
def run_models(info=None): nbprint('Models').push() if info is None: iterate(['models', 'modelinputs', 'num_topics'], [check_input_mat, run_model]) else: info['model_info'] = config.models['list'][info['model_name']] info['model'] = get_model(info) if not info['model'].output_of(info): nbprint('Model is not compatible to inputs.') else: try: check_input_mat(info) run_model(info) except BreakIteration: pass nbprint.pop()
def test_iterate(self): board = np.array([ [0,2,0,0,0], [0,1,0,0,1], [0,2,0,0,0], ]) target = np.array([ [0,0,0,0,0], [2,1,2,0,0], [0,0,0,0,0], ]) board2 = util.iterate(board) np.testing.assert_array_equal( board2, target, )
def test_pad_shape2(self): return board = np.array([ [0,0], [1,1], [1,1], ]) target = np.array([ [-1,-1,-2,-1], [0,0,0,0], [0,1,1,0], [0,1,1,0], [0,0,0,0], ]) board2 = util.iterate(board) np.testing.assert_array_equal( board2, target, )
def run_vectorizer(info=None): nbprint('Vectorizer').push() global runvars if info is None: if config.vectorizer['run_B']: nbprint('BoW').push() runvars = {} iterate(['data', 'token:BC', 'vocab', 'vector:B'], [count_mat, bow]) nbprint.pop() if config.vectorizer['run_C']: nbprint('cBoW').push() runvars = {} iterate(['data', 'token:C', 'vocab', 'vector:C'], [count_mat, cbow]) nbprint.pop() if config.vectorizer['run_P']: nbprint('Phrase').push() runvars = {} iterate(['data', 'vector:P'], [phrase]) nbprint.pop() else: runvars = {} vector_bcp, vector_id = config.split(info['vector_version']) if vector_bcp == 'B' or vector_bcp == 'C': count_mat(info) if vector_bcp == 'B': bow(info) else: cbow(info) else: phrase(info) runvars = None nbprint.pop()
def stop(target): [__stop(service) for service in iterate(target)]
def __enablerepos(repositories): if repositories is None: return '' else: repositories = iterate(repositories) return '--enablerepo=%s ' * len(repositories) % tuple(repositories)
def __enablerepos(repositories): if repositories is None: return '' else: repositories = iterate(repositories) return '--enablerepo=%s ' * len(repositories) % tuple(repositories)
def restart(target): [__restart(service) for service in iterate(target)]
def off(target): [__off(service) for service in iterate(target)]
def on(target): [__on(service) for service in iterate(target)]
def install(target, repositories = None): [__install(package, repositories) for package in iterate(target)]
def reload(target): [__reload(service) for service in iterate(target)]
def install(target, repositories=None): [__install(package, repositories) for package in iterate(target)]