def _finish_setting(self) -> [[int]]: '''when the user input the necessary value for the game, store all the values and draw the game board''' dialog = settings.Setting() dialog.show() if dialog.was_ok_clicked(): # get settings of the game self._rows = dialog.get_rows() self._columns = dialog.get_columns() self._whose_turn = dialog.get_whose_turn() self._tp_position = dialog.get_tp_position() self._win_rule = dialog.get_win_rule() # now layout the game board self._remind_text.set('You can play now !') self._turn_text.set('TURN: {}'.format(self._whose_turn)) self._lines = self._all_lines(self._columns, self._rows) self._p = discs_model.Position(self._rows, self._columns, HEIGHT, WIDTH, transfer_str(self._tp_position)) self._board = discs_model.new_board(self._p) self._state = discs_model.build_new_state( self._p, transfer_str(self._whose_turn)) self._amount_text.set('Black: {} White: {}'.format( self._state.find_black(), self._state.find_white())) self._redraw_all_discs()
def test_Load(self): # Ensure we can enumerate the keys from the settings self.assertGreater(len(settings.Setting.Keys._keys()), 0, "Enumerating all keys returns non-zero list") # Assert loading settings-default.json works self.assertEqual(settings.Setting.Filename(), 'settings-default.json') # Ensure all settings-default.json keys are in default keys defaults = settings.Setting.Defaults() defaultPrefsJson = json.load(open(settings.Setting.Filename())) for jsonKey, v in defaultPrefsJson.iteritems(): self.assertTrue(jsonKey in defaults) # Check that loading a file and converging work converged = settings.Setting().ConvergedDefaults() for covKey, covVal in converged.iteritems(): self.assertTrue(covKey in defaults) # Check that no defaults were dropped off for dKey, dVal in defaults.iteritems(): self.assertTrue(dKey in converged) # And now ensure thre are no extra keys self.assertEqual(len(converged), len(defaults))
model.compile(optimizer=self.optimizer, loss=['categorical_crossentropy'], metrics=['accuracy']) checkpoint_dir = "models/" + str(int(time.time())) + '/' if not os.path.exists(checkpoint_dir): os.makedirs(checkpoint_dir) STAMP = 'lstm_%d_%d_%.1f' % (self.lstm_dim, self.dense_dim, self.drop_prob) filepath= checkpoint_dir + STAMP + "_%s_{val_acc:.2f}.h5"%source_language checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, save_weights_only=True, mode='max') lr_sched = ReduceLROnPlateau(monitor='val_loss', factor=0.2, patience=1, cooldown=1, verbose=1) early_stopping = EarlyStopping(monitor='val_acc', patience=10) model.fit([train_X, train_Y], [train_Z], validation_data = ([val_X, val_Y], [val_Z]), epochs=self.epochs, batch_size = self.batch_size, shuffle = True, callbacks=[checkpoint, lr_sched, early_stopping]) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--source_language', type=str, default='es', help='source_language') params = parser.parse_args() setting = settings.Setting() Tars = NLImodel(setting) Tars.train_model(params.source_language)
def __init__(self): self.settings = settings.Setting().ConvergedDefaults() self.settings['consoletitle'] = True
def method(method, color, color2): setting = settings.Setting() setting.setColors(color, color2) setting.setSetting(method) return "Empty"
def __init__(self): self.settings = settings.Setting().ConvergedDefaults()