def run_app_test(app_name, app, login): """Runs tests for given app.""" uprint('Testing %s... ' % app_name) with mkcd(app_name): try: fetch_code(app['FETCH'], login) build_code(app['BUILD']) print('OK') except CodeFetchError as e: print(e) except CodeBuildError as e: print(e)
def main(): """ Example usage: python -m scripts.compute_trajectories data/eolss-train.pra data/eolss-train.fr > data/eolss-train.trajectories.txt """ try: align_file, src_file = sys.argv[1:] except ValueError: sys.exit('Usage: {} ALIGN_FILE SRC_FILE > OUTPUT_FILE'.format( sys.argv[0])) trajectories = extract_from_ter(align_file, src_file) for idx, src, trg1, trg2, action in full_trajectories(trajectories): uprint(u'|||'.join( [str(idx), src, trg1, trg2, ' '.join(map(unicode, action))]))
prob_sum -= 1./(rank+1) shuffle(words) def plan(self, text): def extract(sentence): return [x for x in jieba.lcut(sentence) if x in self.ranks] keywords = sorted(reduce(lambda x,y:x+y, list(map(extract, split_sentences(text))), []), key = lambda x : self.ranks[x]) words = [keywords[idx] for idx in \ [i for i in range(len(keywords)) if 0 == i or keywords[i] != keywords[i-1]]] if len(words) < 2: self.expand(words, 2) else: while len(words) > 2: words.pop() return words if __name__ == '__main__': planner = Planner() kw_train_data = get_kw_train_data() for row in kw_train_data: num = randint(1,3) uprint(row[1:]) print("num = %d" %num) guess = row[1:num+1] planner.expand(guess, 4) uprintln(guess) assert len(guess) == 4 print()
def paddedPrint(msg): if debug_printing: for i in range(splitWallCoreLevel): utils.uprint(splitWallCorePadding, True) utils.uprint(msg)
def listBrushes(map): brush_planes = [] # stores the (6) planes that make up one brush plane_points = [] # stores the (3) points in the current plane psa = [] # store one set of non-parallel planes psb = [] # store another set of non-parallel planes textureSpec = '' # Process all brushes... for brush in map.getElementsByTagName('brush'): utils.uprint('Brush...') # Get all planes... for plane in brush.getElementsByTagName('plane'): utils.uprint(' Plane...') # Get texture spec... textureSpec = getText( plane.getElementsByTagName('texture')[0].childNodes) utils.uprint(' Texture: ' + textureSpec) # Get all points... for point in plane.getElementsByTagName('point'): point_match = r_planepoints.match(getText(point.childNodes)) plane_points.append( Point(float(point_match.group(1)), float(point_match.group(2)), float(point_match.group(3)))) # NB: We use floats above so that later calculations are still accurate. utils.uprint(' ' + str(plane_points[len(plane_points) - 1])) # Put points into a plane object... brush_planes.append( Plane3D(plane_points[0], plane_points[1], plane_points[2])) plane_points = [] # Grab texture and remove this plane... brush.removeChild(plane) # Got all planes; work out brush origin and size... for plane in brush_planes: utils.uprint(' ' + str(plane)) # Get and solve parallel planes... while len(brush_planes) > 0: t = brush_planes.pop(0) s = t.N.x + t.N.y + t.N.z if s > 0: psa.append(t) else: psb.append(t) i1 = intersect(psa[0], psa[1], psa[2]) i2 = intersect(psb[0], psb[1], psb[2]) # Work out size (from smallest/lowest coord) and extent... i1s = i1.x + i1.y + i1.z i2s = i2.x + i2.y + i2.z if i1s < i2s: origin = i1 extent = i2 - i1 else: origin = i2 extent = i2 - i1 # Update brush info... brush.setAttribute('origin', str(origin)) brush.setAttribute('extent', str(extent)) brush.setAttribute('texture', textureSpec) # Tidy up... psa = [] psb = []
def main(): int2ch, _ = get_vocab() print "Size of the vocabulary: {}".format(len(int2ch)) for ch in int2ch[:100]: uprint(ch)