def __init__(self, save_path=None, dataset='mnist', n_classes = 10, n_epochs = 50, batch_size=64, lr=0.001, checkpoint_save = 1, checkpoint_test=5, training_data_ratio=0.8, labeled_data_ratio=1, ): ''' :param batch_size: batch_size for training data :param training_data_ratio: training data ratio ''' BaseClass.__init__( self, save_path=save_path, n_classes = n_classes, dataset=dataset, n_epochs = n_epochs, batch_size=batch_size, lr=lr, checkpoint_save = checkpoint_save, checkpoint_test= checkpoint_test, ) self.data_loader(labeled_data_ratio, training_data_ratio, dataset=dataset)
def __init__(self, com, name, a, d): BaseClass.__init__(self) self.debug = True if d > 0 else False self.auto = True if a > 0 else False self.name = name self.com = com self.com.regEvt("join", self.join) self.com.regEvt("players", self.players_change) self.com.regEvt("stdin", self.process_stdin) self.com.regEvt("chat", self.chat) self.com.regEvt("deal", self.deal) self.com.regEvt("uno", self.uno) self.com.regEvt("played", self.played) self.com.regEvt("startgame", self.gamestart) self.com.regEvt("go", self.go) self.com.regEvt("invalid", self.invalid) self.com.regEvt("gg", self.gg) self.com.regEvt("wait", self.wait) self.status = 0 #0: not in, 1: waiting, 2: playing self.playerList = [] self.cards = [] self.myTurn = False
def __init__(self, save_path=None, n_classes=10, dataset='mnist', n_epochs=50, batch_size=64, lr=0.001, checkpoint_save=1, checkpoint_test=5, alpha=0.8, labeled_data_ratio=1, training_data_ratio=0.8): ''' :param batch_size: batch_size for training data :param alpha: Beta distribution parameter, used for MatchUp training :param training_data_ratio: training data ratio ''' BaseClass.__init__( self, save_path=save_path, n_classes=n_classes, dataset=dataset, n_epochs=n_epochs, batch_size=batch_size, lr=lr, checkpoint_save=checkpoint_save, checkpoint_test=checkpoint_test, ) self.alpha = alpha self.data_loader(labeled_data_ratio, training_data_ratio, dataset=dataset)
def __init__(self, host, port, name, debug): BaseClass.__init__(self) self.port = port self.host = host self.name = name self.debug = True if debug > 0 else False signal.signal(signal.SIGINT, self.sighandler) self.accepted = False self.start_time = time.time()
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, -1) self.custom_data = {} self.next_color = 0 self.font = tkFont.Font(family='Helvetica', size=64, weight='bold') self.phone_fn = tkFont.Font(family='Helvetica', size=32, weight='bold')
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.COLS = int(width / self.TILE_SIZE) self.ROWS = int(height / self.TILE_SIZE) # list of rectangles self.rects = [] self.image = None
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.time_font = tkFont.Font(family='Helvetica', size=28, weight='bold') self.number_font = tkFont.Font(family='Helvetica', size=28, weight='normal', slant='italic') self.date_font = tkFont.Font(family='Helvetica', size=18, weight='normal') self.items = [] self.reset_time = None
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.small_font = tkFont.Font(family='Helvetica', size=16, weight='normal') self.small_bold_font = tkFont.Font(family='Helvetica', size=16, weight='bold') self.days_to_show = 31 # these will be re-created when changing parameters self.d_items = []
def __init__(self, game, cd_kick): BaseClass.__init__(self) self.game = game self.deck = Deck() self.current_card = None self.players = [] self.turn = 0 self.played_time = None self.timeout = cd_kick self.turn_direction = 1 self.playing = False
def __init__(self, canvas, width, height, image_manager): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.my_images = image_manager self.btn_size = 80 self.color = 0 self.pixel_size = 8 self.start = None self.__shapes = []
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, TIMEOUT) self.settings = { SETTING_NUM_BOMBS: 3 } self.__cols = int(width / TILE_SIZE) self.__rows = int(height / TILE_SIZE) - 1 self.__rects = [] self.alive = False
def test_attack_with_wrong_command(self): obj = BaseClass(3,4) weapon = Weapon("Despod",444) obj.equip(weapon) obj.attack("weapon") with self.assertRaises(ValueError): obj.attack("Genadi")
def kick_player(self, playerId): try: p = self.by_id(playerId) except: print "cant not find player:%d" % playerId return if self.turn == playerId: self.set_turn(1) p.dispose() self.players.remove(p) BaseClass.exeEvt(self, 'kick', playerId) if len(self.players) == 1: #win BaseClass.exeEvt(self, 'won', self.players[0].playerId)
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.settings = { self.SETTING_PLAYER1: get_next_icon_filename(None), self.SETTING_PLAYER2: get_next_icon_filename(None), } self.players = [] self.prev_btn = None self.run = 0 self.hide_buttons = None self.current_player = 1 self.buttons = [] self.pieces = [] self.btn_exit = None self.btn_new_game = None
def __init__(self, save_path=None, n_classes=10, dataset='mnist', n_epochs=50, lr=0.001, batch_size_l=64, batch_size_u=None, K=2, temperature=0.5, ULoss_factor=100, checkpoint_save=1, checkpoint_test=5, alpha=0.75, labeled_data_ratio=0.1, training_data_ratio=0.8): ''' :param batch_size_l: batch_size for labeled data :param batch_size_u: batch_size for unlabeled data :param K: number of augmentations for unlabeled data :param temperature: parameter for distribution sharpening for unlabeled labels generation :param ULoss_factor: factor for unlabeled loss in total loss. Labeled loss factor is set to 1 :param alpha: Beta distribution parameter, used for MatchUp training :param labeled_data_ratio: labeled data ratio :param training_data_ratio: training data ratio ''' BaseClass.__init__(self, save_path=save_path, n_classes=n_classes, dataset=dataset, n_epochs=n_epochs, batch_size=batch_size_l, lr=lr, checkpoint_save=checkpoint_save, checkpoint_test=checkpoint_test) self.batch_size_l = batch_size_l self.batch_size_u = batch_size_u self.K = K self.temperature = temperature self.ULoss_factor = ULoss_factor self.alpha = alpha self.data_loader(labeled_data_ratio, training_data_ratio, dataset=dataset)
def __init__(self, com, minPl, maxPl, cd_join, cd_kick, d): BaseClass.__init__(self) self.com = com self.minPl = minPl self.maxPl = maxPl self.maxQueue = 20 self.cd_join = cd_join self.cd_kick = cd_kick self.com.regEvt("chat", self.chat) self.com.regEvt("join", self.join) self.com.regEvt("play", self.pl_play) self.com.regEvt("client_error", self.cl_er) self.clients = [] self.debug = d
def play(self, playerId, msg): if not self.playing: raise NotPlaying() if self.turn != playerId: raise NotTurn(playerId) p = self.by_id(playerId) p.play(msg) self.game.com_bc_play(p.playerId, msg) self.game.com_s_go(self.turn, self.current_card.toString()) if p.is_won(): self.game.com_bc_gg(playerId) BaseClass.exeEvt(self, 'won', playerId) if p.is_uno(): self.game.com_bc_uno(playerId) self.played_time = time.time()
def test_check_dns(self): bc = BaseClass() self.assertEqual(bc.callwithhttplib(), 200, bc.queryresponse) bc.isrunwithjsonfile() # check if continue with system.cfg -> test_json_file self.assertIsNotNone(bc.convertjson(bc.data), 'Invalid Response:\n' + bc.data) self.assertTrue(bc.parsejson(bc.objjson), 'Invalid Json:\n' + bc.data) self.assertTrue(bc.overallstatus, Config.readdnserror())
def test_List_Time_Zone_TC4(): Base = BaseClass() Base.Timezone("List_Time_Zone", "List_Time_Zone_TC4",Variables["api_base_url"], Variables['Invalid_Key'])
def __init__(self, id, name): print("__init from " + __name__) BaseClass.__init__(self, id, name)
def __init__(self, health, mana, damage): BaseClass.__init__(self, health, mana) self.damage = damage self.cord_x = None self.cord_Y = None
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, 60)
def __init__(self, name, title, health, mana, mana_regeneration_rate): self.name = name self.title = title self.mana_regeneration_rate = mana_regeneration_rate self.money = 0 BaseClass.__init__(self, health, mana)
def test_Get_Time_Zone_TC2(): Base=BaseClass() Base.Timezone("Get_Time_Zone", "Get_Time_Zone_TC2")
def test_Get_Time_Zone_TC10(): Base=BaseClass() Base.Timezone("Get_Time_Zone", "Get_Time_Zone_TC10", Variables["vpi_api_base_url"])
def test_Convert_Time_Zone_TC2(): Base = BaseClass() Base.Timezone("Convert_Time_Zone", "Convert_Time_Zone_TC2")
def test_Convert_Time_Zone_TC4(): Base = BaseClass() Base.Timezone("Convert_Time_Zone", "Convert_Time_Zone_TC4", Variables["api_base_url"], Variables['Key_2'])
def test_List_Time_Zone_TC2(): Base=BaseClass() Base.Timezone("List_Time_Zone", "List_Time_Zone_TC2")
def __init__(self, port, debug): BaseClass.__init__(self) self.port = port self.debug = True if debug > 0 else False
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT) self.COLS = int(width / self.TILE_SIZE) self.ROWS = int(height / self.TILE_SIZE)
def test_wrong_value_in_constructor(self): with self.assertRaises(ValueError): BaseClass(2,"Ivan")
def __init__(self, canvas, width, height): BaseClass.__init__(self, canvas, width, height, self.TIMEOUT)
import sys import os from MyConstants import PathConstants as PC, ClassConstants as CC, GeneralConstants as GC from importlib import import_module from BaseClass import BaseClass from AggregatorBase import AggregatorBase configs = sys.argv executable_path = sys.argv[0] conf_module = sys.argv[1] # a name of .py file without the .py extension just as you use it in import statement conf = import_module(conf_module).Conf executable_folder_path = os.path.dirname(executable_path) conf_full_file_name = f'{conf_module}.py' conf_path = os.path.join(executable_folder_path, conf_full_file_name) conf[PC.ConfFilePath] = conf_path agg = BaseClass.instantiate_class(conf, conf[GC.Aggregator])