def openAnnotFile(self, var=None): var.set(askopenfilename()) row = 2 master = self.master try: with open(var.get(), 'r') as ANNOT: keyList = ANNOT.readline().strip().split("\t")[1:] #print(keyList) keyList.sort() keyString = ",".join(keyList) except FileNotFoundError: return self.optionLabel = Label(master, text="Annotation keys") self.optionLabel.grid(row=row, column=0, sticky=W, padx=3) self.k = StringVar() self.k.set(keyString) self.optionEntry = Entry(master, width=WIDTH, textvariable=self.k) self.optionEntry.grid(row=row, column=1, padx=3) self.optionLabel2 = Label(master, text="comma-separated") self.optionLabel2.grid(row=row, column=3, sticky=W, padx=3) ann = os.path.basename(self.a.get()) CreateToolTip( self.optionEntry, """List of available attributes in file %s.\nIf you wish to remove some, click on line and edit.""" % ann) self.master.update_idletasks() RHeight = self.master.winfo_reqheight() RWidth = self.master.winfo_reqwidth() self.master.geometry(("%dx%d+300+300") % (RWidth, RHeight)) center(self.master)
def __init__(self, killcount, score, level): State.__init__(self) self.next = StartMenu() self.screen = pygame.display.get_surface() alpha_bg = self.screen.copy() alpha_bg.set_alpha(99) self.bg = pygame.Surface((800, 600)) self.bg.fill((0, 0, 0)) self.bg.blit(alpha_bg, (0, 0)) img = data.load_image("gameover.png") pos = utils.center(img.get_size(), (800, 600)) self.bg.blit(img, pos) img = TextLine("You killed " + str(killcount) + " zombies.", 30) pos = utils.center(img.get_size(), (800, 600)) self.bg.blit(img, (pos[0], 325)) scorelist = HIGHSCORE.keys() scorelist.sort() for s in scorelist: if score > s: self.next = EnterHighscore(score, level) break self.update_scr = True
def test_center(self): """ Test for the center function used to center text on screen """ my_message = "Hello I'm a test message" self.assertEqual(utils.center(my_message, 30), " Hello I'm a test message ") self.assertEqual(utils.center(my_message, 20), "Hello I'm a test message") # NOTE: On odd lenght final size won't be equal to max_line_size my_odd_message = "Hello I have a test message" self.assertEqual(utils.center(my_odd_message, 30), " Hello I have a test message ")
def print_bad_entities(self): # pragma: no cover """ Print all bad function with colors """ print("-" * TITLE_WIDTH) print(center("Bad files", TITLE_WIDTH)) print("-" * TITLE_WIDTH) self.print_bad_files() print("\n\n", end='') print("-" * TITLE_WIDTH) print(center("Bad functions", TITLE_WIDTH)) print("-" * TITLE_WIDTH) self.print_bad_functions()
def __init__(self, req_tree, level=1): State.__init__(self) self.screen = pygame.display.get_surface() self.bg = self.screen.copy() images = data.load_gfx(["deathblossom.png"]) self.cursor = Cursor(images["deathblossom.png"]) self.sprites = pygame.sprite.RenderUpdates() self.sprites.add(self.cursor) img = data.load_image("perkboard.png") self.offset = utils.center(img.get_size(), (800, 600)) self.bg.blit(img, self.offset) img = TextLine("Level: " + str(level)) self.bg.blit(img, (600, 400)) self.highlight = [] for p in req_tree.keys(): if req_tree[p] is True: ppos = perk[p]["pos"] x = self.offset[0] + ppos[0] y = self.offset[1] + ppos[1] self.bg.blit(perk[p]["img_p"], (x, y)) self.highlight.append(ToolTipArea([x, y, 32, 32], p)) self.tooltip = ToolTip() self.update_scr = True
def print_header(self): print('+' + 50 * '-' + '+') print('|' + 50 * ' ' + '|') print('|' + 21 * ' ' + 'natseloG' + ' ' * 21 + '|') print('|{}|'.format(center(jdatetime.datetime.now().strftime("%d %b %Y || %H:%M"), 50))) print('|' + 50 * ' ' + '|') print('+' + 50 * '-' + '+')
def __init__(self, score="00000001", level="1"): State.__init__(self) self.next = StartMenu() self.screen = pygame.display.get_surface() alpha_bg = self.screen.copy() alpha_bg.set_alpha(99) self.bg = pygame.Surface((800, 600)) self.bg.fill((0, 0, 0)) self.bg.blit(alpha_bg, (0, 0)) img = data.load_image("newhighscore.png") pos = utils.center(img.get_size(), (800, 600)) self.bg.blit(img, pos) self.level = level self.score = score self.score_img = TextLine(score) self.score_img.set_position((470, 250)) self.entry = TextEntry() self.entry.set_position((190, 250)) self.entry.gen_image() self.update_scr = True self.play_snd = True
def get_pair(self): dice = self.locate_dice() dice_dict = {} for x, y, w, h in dice: dice_dict[(x, y, w, h)] = self.get_dots((x, y, w, h)) path_centers = [] for i in range(0,6): for j in range (i+1,6): if dice_dict[dice[i]] + dice_dict[dice[j]] == 7 or dice_dict[dice[i]] + dice_dict[dice[j]] == 11: path_centers.append((utils.center(dice[i]), utils.center(dice[j]))) low = 0 for i in range(1, len(path_centers)): if utils.dist(path_centers[i]) < utils.dist(path_centers[low]): low = i
def main(): # pragma: no cover """ main du programme. this function is not covered by coverage.py """ print("*" * FRAME_SIZE) print(center("PySMAnalyzer programmed with {} by cutty853".format( colourizer.good("love") ), FRAME_SIZE)) parser = define_parser() options = parser.parse_args() if options.test: import test import sys print(center("Loading all the unit-test of the project", FRAME_SIZE)) print("*" * FRAME_SIZE) result = test.run() sys.exit(not result) print("*" * FRAME_SIZE, "\n") if not options.input or not options.rules: import sys print("You must provide a input file and a rules file") print("-" * FRAME_SIZE) parser.print_help() sys.exit(1) if options.format not in {"html", "xml", "str"}: import sys print("You must provide a supported format (html or xml or str)") print("-" * FRAME_SIZE) parser.print_help() sys.exit(1) sm_analyzer = analyzer.Analyzer(options.input, options.rules) sm_analyzer.load_files() sm_analyzer.make_report() if options.format == "str": sm_analyzer.print_bad_entities() else: print("generating output to the {} format".format( colourizer.good(options.format) )) if options.output: filename = sm_analyzer.save_report(options.output, method=options.format) print("output:", os.path.realpath(filename))
def measurements(self, frame, contours): distances = [] distance = None angle = None if contours and self.main.results.camera == 'realsense': for cnt in contours: (x, y) = utils.center(cnt) distances.append( self.main.display.camera_provider.get_distance(x, y)) distance = min(distances) closest = contours[distances.index(distance)] (x, y) = utils.center(closest) angle = utils.angle(constants.FOCAL_LENGTHS['realsense'], x, frame) if distance: cv2.putText(frame, str(int(distance * 100)), (x, y), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 0, 255), 1, cv2.LINE_AA) return distance, angle, None, None
def _make_lost_overlay(self): overlay = pygame.Surface((self.game_width, self.game_height), pygame.SRCALPHA) overlay.fill((255, 255, 255, 128)) label = self.font.render('YOU LOST!', True, (0, 0, 0)) width, height = label.get_size() overlay.blit(label, (center(self.game_width, width), self.game_height / 2 - height - 10)) return overlay, self._draw_button(overlay, 'Try Again', lambda w, h: ((self.game_width - w) / 2, self.game_height / 2 + 10))
def main(xmlFile=None): if not xmlFile: sys.exit("No configuration file given; exiting") def on_configure(event): # update scrollregion after starting 'mainloop' # when all widgets are in canvas canvas.configure(scrollregion=canvas.bbox('all')) # initialize root object root = tk.ThemedTk() root.configure(background="lightgrey") s = Style() s.theme_use('radiance') canvas = Canvas(root) canvas.pack(side=LEFT) scrollbar = Scrollbar(root, command=canvas.yview) scrollbar.pack(side=RIGHT, fill='y') canvas.configure(yscrollcommand=scrollbar.set) # call object app = Application(root, XML=xmlFile) root.update_idletasks() root.canvas = canvas # update scrollregion after starting 'mainloop' # when all widgets are in canvas canvas.bind('<Configure>', on_configure) canvas.create_window((0, 0), window=app, anchor='nw') RHeight = min(700, app.winfo_reqheight()) RWidth = app.winfo_reqwidth() canvas.configure(width=RWidth, height=RHeight) root.bind('<Button-4>', lambda event: canvas.yview_scroll(-1, 'units')) root.bind('<Button-5>', lambda event: canvas.yview_scroll(1, 'units')) center(root) # enter main loop root.mainloop() return (app.returnValue)
def main(prog, args=None): root = tk.ThemedTk() root.configure(background="lightgrey") s = Style() s.theme_use('radiance') root.minsize(width=500, height=200) newArgs = MyGUI(root, title=prog, args=args) root.update_idletasks() RHeight = root.winfo_reqheight() RWidth = root.winfo_reqwidth() root.geometry(("%dx%d+300+300") % (RWidth, RHeight)) root.bind("<Return>", newArgs.run) root.bind("<Escape>", newArgs.Quit) center(root) root.wait_window(newArgs.master) try: #print(args.arguments) factorgraph.Main(**newArgs.arguments) except: root.destroy
def __init__(self, border, tops): self.border = border self.tops = tops self.levels = [] n = len(tops) for i in range(n): border = [Vec3(p.x, p.y, p.z + i * 2.5) for p in self.border] c = center(border) border = [lerp(p, c, 1 - 0.99**i) for p in border] top = (i + 1) * 2.5 level = Level(border=border, top=top, cover=True) self.levels.append(level)
def PCA(X, compos): """ return the compos highest eigenvalues and corresponding eigenvectors, of the covariance matrix of X (using the XX.T trick) """ X = center(X) X = np.matrix(X) cov = np.dot(X, X.T) compos = min(compos, matrix_rank(cov)) # keep only useful info. lamb, V = eig(cov) ind = (-lamb).argsort() # sort the eigenvalues ind = ind[:compos] # keep only the compos best #print "loss : {} %".format(100.0 * (1 - np.sum(lamb[ind]) / np.sum(lamb))) # print the loss of variance. return lamb[ind], np.matrix(V[:, ind])
def update(self): if self.zoom != self.tilemap.zoom: self.zoom_changed() elif not self.unit.was_modified(): return logging.debug("Sprite update: %s" % self.unit.name) w, h = self.rect.size mw, mh = img_max_size = (w, h - 5) mw2, mh2 = mw // 2, mh // 2 self.image.fill((0, 0, 0, 0)) pygame.draw.circle(self.image, self.unit.team.color, (mw2, mh2), mh2, 3) src_img = self.unit.image if src_img is None: self.image.blit( src_img, utils.center(self.image.get_rect(), src_img.get_rect())) else: image_size = utils.resize_keep_ratio(src_img.get_size(), img_max_size) resized_image = pygame.transform.smoothscale( src_img, image_size).convert_alpha() self.image.blit( resized_image, utils.center(self.image.get_rect(), resized_image.get_rect())) hp_bar_length = int(self.unit.health / self.unit.health_max * self.rect.w) hp_bar = pygame.Surface((hp_bar_length, 5)) hp_bar.fill((0, 255, 0)) self.image.blit(hp_bar, (0, self.rect.h - 5)) if self.team.is_boss(self.unit): icon = pygame.Surface((3, 3)) icon.fill(c.BLUE) self.image.blit(icon, (0, self.rect.h - 4))
def __init__(self, screen, msg): State.__init__(self) self.screen = pygame.display.get_surface() self.msg = msg self.msg_pos = utils.center(self.msg.get_size(), self.screen.get_size()) if not screen: self.bg = pygame.Surface((800,600)) else: self.bg = screen.copy() self.bg.set_alpha(100) self.scr_update = 1
def __init__(self, name="Scavenger"): State.__init__(self) self.screen = pygame.display.get_surface() alpha_bg = self.screen.copy() alpha_bg.set_alpha(99) self.bg = pygame.Surface((800, 600)) self.bg.fill((0, 0, 0)) self.bg.blit(alpha_bg, (0, 0)) self.perk = perk[name] gfx = data.load_gfx( ["newperk.png", "deathblossom.png", "donateblood.png"]) deco = gfx["donateblood.png"] img = gfx["newperk.png"] pos = utils.center(img.get_size(), (800, 600)) self.bg.blit(img, pos) img = self.perk["img_t"] x = utils.center(img.get_size(), (800, 600))[0] self.bg.blit(img, (x, pos[1] + 50)) img = self.perk["img_p"] x = utils.center(img.get_size(), (800, 600))[0] self.bg.blit(img, (x, pos[1] + 75)) img = TextArea(self.perk["desc"]) x = utils.center(img.get_size(), (800, 600))[0] self.bg.blit(img, (x, pos[1] + 110)) img = data.load_image("pause.png") self.bg.blit(img, (335, 525)) self.update_scr = True cursor = Cursor(gfx["deathblossom.png"]) self.sprites = pygame.sprite.RenderUpdates() self.sprites.add(cursor) self.cont = ClickArea([334, 408, 125, 25], (320, 408), deco, (463, 408))
def __getitem__(self, batch_idx): X = self.X[batch_idx * self.batch_size: (batch_idx + 1) * self.batch_size] y = self.y[batch_idx * self.batch_size: (batch_idx + 1) * self.batch_size] batch_x = np.zeros(shape=(len(X), self.img_height, self.img_width, 3), dtype=np.float32) batch_y = np.zeros(shape=len(X), dtype=np.float32) for i in range(len(X)): img = utils.random_rotate_45(io.imread(X[i])) batch_x[i] = transform.resize(img, output_shape=(self.img_height, self.img_width), preserve_range=True).astype('uint8') batch_y[i] = y[i] return utils.center(batch_x), batch_y
def __getitem__(self, batch_idx): X = self.X[batch_idx * self.batch_size: (batch_idx + 1) * self.batch_size] y = self.y[batch_idx * self.batch_size: (batch_idx + 1) * self.batch_size] batch_x = np.zeros(shape=(len(X), self.img_height, self.img_width, 3), dtype=np.float32) batch_y = np.zeros(shape=len(X), dtype=np.float32) for i in range(len(X)): batch_x[i] = transform.resize(io.imread(X[i]), output_shape=(self.img_height, self.img_width), preserve_range=True).astype('uint8') batch_y[i] = sum(data['occupied'] for data in _parse_xml(y[i])) return utils.center(batch_x), batch_y
def _create_loss(self): # Hard loss logQHard, samples = self._recognition_network() reinforce_learning_signal, reinforce_model_grad = self._generator_network(samples, logQHard) logQHard = tf.add_n(logQHard) # REINFORCE learning_signal = tf.stop_gradient(U.center(reinforce_learning_signal)) self.optimizerLoss = -(learning_signal*logQHard + reinforce_model_grad) self.lHat = map(tf.reduce_mean, [ reinforce_learning_signal, U.rms(learning_signal), ]) return reinforce_learning_signal
def _create_loss(self): # Hard loss logQHard, samples = self._recognition_network() reinforce_learning_signal, reinforce_model_grad = self._generator_network( samples, logQHard) logQHard = tf.add_n(logQHard) # REINFORCE learning_signal = tf.stop_gradient(U.center(reinforce_learning_signal)) self.optimizerLoss = -(learning_signal * logQHard + reinforce_model_grad) self.lHat = map(tf.reduce_mean, [ reinforce_learning_signal, U.rms(learning_signal), ]) return reinforce_learning_signal
def __init__(self): State.__init__(self) self.next = StartMenu() self.screen = pygame.display.get_surface() self.screen.fill((0, 0, 0)) self.logo = data.load_image("logo.png") self.alpha = 0 self.logo.set_alpha(0) self.logopos = utils.center(self.logo.get_size(), (800, 600)) self.fadeout = False self.anim_timer = utils.Timer(1) data.set_music("logovoices.ogg") pygame.mixer.music.play() self.update_scr = True
def measurements(original, contours): if not contours: return None, None distances = [] for cnt in contours: points = utils.box(cnt) if not points.any(): return None, None avg_real_heights = sum(utils.power_cube.values()) / len( utils.power_cube) heights = [] for i, point in enumerate(points): x = point[0] - points[i - 1][0] y = point[1] - points[i - 1][1] height = math.hypot(x, y) heights.append(height) if len(points) == 5: max_height = max(heights) half_height = max_height / 2 heights.remove(max_height) heights.extend([half_height] * 2) avg_heights = sum(heights) / len(heights) distances.append( (avg_real_heights * constants.FOCAL_LENGTHS['lifecam']) / avg_heights) min_distance = min(distances) chosen_one = contours[distances.index(min_distance)] angle = utils.angle(constants.FOCAL_LENGTHS['lifecam'], utils.center(chosen_one)[0], original) return angle, min_distance
def __init__(self, req_tree, level): State.__init__(self) self.screen = pygame.display.get_surface() self.req_tree = req_tree self.level = level alpha_bg = self.screen.copy() alpha_bg.set_alpha(99) self.bg = pygame.Surface((800, 600)) self.bg.fill((0, 0, 0)) self.bg.blit(alpha_bg, (0, 0)) img_names = [ "escmenu.png", "deathblossom.png", "donateblood.png", "pause.png" ] images = data.load_gfx(img_names) img = data.load_image("pause.png") self.bg.blit(img, (335, 525)) self.deco = images["donateblood.png"] self.menu = images["escmenu.png"] self.menu_pos = utils.center(self.menu.get_size(), (800, 600)) self.bg.blit(self.menu, self.menu_pos) self.cursor = Cursor(images["deathblossom.png"]) self.sprites = pygame.sprite.RenderUpdates() self.sprites.add(self.cursor) self.update_scr = True self.cont = ClickArea([311, 217, 178, 25], (325, 220), self.deco, (459, 220)) self.perk = ClickArea([311, 278, 178, 25], (310, 280), self.deco, (476, 280)) self.surr = ClickArea([311, 339, 178, 25], (315, 342), self.deco, (470, 342)) self.buttons = [self.cont, self.perk, self.surr]
# Try different values and see how this changes # the quality of the denoised image SIZE = 7 patch_size = (SIZE, SIZE) # We want all overlapping image patches so we set this as None max_patches = None # Convert the image into a matrix of image patches # Each column in the matrix 'image_patches' correspond # to one image patch. Shape (num_elements_in_patch, n_patches), # In this case (12*12, n_patches) image_patches = create_patches(noisy_image, patch_size, max_patches) # Remove the mean from the patches for better results image_patches, mean = center(image_patches) # The dictionary and image_patches needs the same number of rows rows = image_patches.shape[0] # Number of dictionary atoms. This can technically by any number, buy # 2*rows is usually a good choice N_ATOMS = 23 dictionary = initial_dictionary(rows, N_ATOMS) # dictionary = np.load('dictionary.npy') # Number of K-SVD iterations ITERS = 2 # Number of nonzero coeffs to use in K-SVD sparse coding step N_NONZERO = 1
with open(directory['working-set']['fields'],READ) as f: fields = map(format,f.readlines()) field_types = json.load(open(directory['field-types'],READ)) #Case the numerical features from str to int or float patients = [{key:value if field_types[key] == 'str' else eval('%s(%s)'%(field_types[key],value)) for key,value in patient.iteritems()} for patient in [dict(zip(fields,patient)) for patient in data]] #Center the ones that were cast to type float. They represent continuous variables for patient in patients: for variable in patient: if type(patient[variable]) is float: tmp = patient[variable] patient[variable] = tech.center(tmp) #Split into testing and training #Randomize by shuffling and then splitting in half random.shuffle(patients) training = patients[:len(patients)/2] testing = patients[len(patients)/2:] #Get feature vectors zero-centered with mean variance. #First let's extract features vec = DictVectorizer() x = vec.fit_transform(training).toarray() y = vec.transform(testing).toarray()
return all_data def getFileMin_Max(self, options): filename = askopenfilename(**options) if filename: f = open(filename) data = [line.replace("\n", " ")[0:] for line in f.readlines()[0:]] all_data = np.zeros(len(data)) for i in range(len(data)): datos = data[i].split() all_data[i] = float(datos[1]) f.close() return all_data def frange(self, start, stop, step): i = start while i <= stop: yield i i += step ventanaPrincipal = Tk() app = App(ventanaPrincipal) ventanaPrincipal.wm_title("Fatiga") ventanaPrincipal.geometry("1170x980") utils.center(ventanaPrincipal) ventanaPrincipal.deiconify() ventanaPrincipal.mainloop()
def center(self, surf): pos = utils.center(self.image.get_size(), surf.get_size()) self.set_position(pos)
def call(self, inputs, training=None): _, w, h, c = K.int_shape(inputs) bs = K.shape(inputs)[0] m, f = utils.center(inputs, self.moving_mean, self.instance_norm) get_inv_sqrt = utils.get_decomposition(self.decomposition, bs, self.group, self.instance_norm, self.iter_num, self.epsilon, self.device) def train(): ff_aprs = utils.get_group_cov(f, self.group, self.m_per_group, self.instance_norm, bs, w, h, c) if self.instance_norm: ff_aprs = tf.transpose(ff_aprs, (1, 0, 2, 3)) ff_aprs = (1 - self.epsilon) * ff_aprs + tf.expand_dims( tf.expand_dims(tf.eye(self.m_per_group) * self.epsilon, 0), 0) else: ff_aprs = (1 - self.epsilon) * ff_aprs + tf.expand_dims( tf.eye(self.m_per_group) * self.epsilon, 0) whitten_matrix = get_inv_sqrt(ff_aprs, self.m_per_group)[1] self.add_update([ K.moving_average_update(self.moving_mean, m, self.momentum), K.moving_average_update( self.moving_matrix, whitten_matrix if '_wm' in self.decomposition else ff_aprs, self.momentum) ], inputs) if self.renorm: l, l_inv = get_inv_sqrt(ff_aprs, self.m_per_group) ff_mov = (1 - self.epsilon) * self.moving_matrix + tf.eye( self.m_per_group) * self.epsilon _, l_mov_inverse = get_inv_sqrt(ff_mov, self.m_per_group) l_ndiff = K.stop_gradient(l) return tf.matmul(tf.matmul(l_mov_inverse, l_ndiff), l_inv) return whitten_matrix def test(): moving_matrix = (1 - self.epsilon) * self.moving_matrix + tf.eye( self.m_per_group) * self.epsilon if '_wm' in self.decomposition: return moving_matrix else: return get_inv_sqrt(moving_matrix, self.m_per_group)[1] if self.instance_norm == 1: inv_sqrt = train() f = tf.reshape(f, [-1, self.group, self.m_per_group, w * h]) f_hat = tf.matmul(inv_sqrt, f) decorelated = K.reshape(f_hat, [bs, c, w, h]) decorelated = tf.transpose(decorelated, [0, 2, 3, 1]) else: inv_sqrt = K.in_train_phase(train, test) f = tf.reshape(f, [self.group, self.m_per_group, -1]) f_hat = tf.matmul(inv_sqrt, f) decorelated = K.reshape(f_hat, [c, bs, w, h]) decorelated = tf.transpose(decorelated, [1, 2, 3, 0]) return decorelated
def __init__(self): State.__init__(self) pygame.key.set_repeat(20, 50) Zombie.hp_max = 5 Zombie.dam = 2 self.screen = pygame.display.get_surface() self.screen.fill((0, 0, 0)) self.killcount = 0 #zombies self.zombie_timer = utils.Timer(100) self.zombie_spawn = 1 self.max_zombies = 150 self.ztrack = 9 self.zombie_wave = 0 self.moan_timer = utils.Timer(random.randint(20, 60)) self.zombie_sndlist = SND_MOAN #load graphics self.dc_gfx = data.load_game_gfx() #set bg self.bg = self.dc_gfx["bg.png"] self.lawn = self.screen.subsurface([0, 35, 800, 565]) self.update_bg() #spritegroups self.bullets = pygame.sprite.Group() self.powerups = pygame.sprite.Group() self.on_bottom = pygame.sprite.Group() self.zombies = pygame.sprite.Group() self.on_top = pygame.sprite.Group() self.all_sprites = pygame.sprite.Group() #generate zombie imagelist self.zombie_namelist = [] for i in xrange(1, 11): nr = str(i) if len(nr) == 1: nr = "0" + nr name = "zombie" + nr + ".png" self.zombie_namelist.append(name) if SH_MODE == [True]: self.zombie_namelist = ["sheep.png"] self.zombie_sndlist = {"sheep": SND_MAIN["zombiesheep.ogg"]} self.zombie_spawn = 7 self.moan_timer.set_interval(40) #cursor animlist = data.load_grid("reload.png") self.cursor = AnimCursor(self.dc_gfx["deathblossom.png"], animlist) pos = utils.center((60, 60), self.lawn.get_size()) pygame.mouse.set_pos(pos) self.on_top.add(self.cursor) self.hover_hp = HoverHP() #player self.player = Player(self.dc_gfx["mcgrumpington.png"], self.cursor) self.player.center(self.screen) self.all_sprites.add(self.player) self.gen_zombies(self.zombie_spawn) data.set_music("bgm.xm") pygame.mixer.music.play(-1)
import utils, SMF import numpy as np train_data = utils.read('train_user_item_score.txt') valid_data = utils.read('validation_user_item_score.txt') edge_list = utils.read('users_connections.txt') MAX_ID = int(np.max(train_data, axis=0)[0]) LIMIT = 1 network, network_transpose = utils.edge_list_to_adj_list( MAX_ID, edge_list, LIMIT) train_mean = utils.center(train_data) valid_data[:, 2] -= train_mean # ---------------------------------- # train Model # ---------------------------------- sigma = 1 sigma_u = 1 sigma_v = 1 sigma_w = 1 D = 1 iterations = 10 model = SMF.Model(train_data, network, network_transpose, D, sigma, sigma_u, sigma_v, sigma_w, iterations) rmse_list = model.train()