def __init__(self, config, progress, restart): self.logger = logging.getLogger(self.__class__.__name__) self.progress = progress self.basedir = None self.random = config.get('randomization', False) if 'devices' not in config: raise ConfigError('"device" is required in the configuration') adb_path = config.get('adb_path', 'adb') self.devices = Devices(config['devices'], adb_path=adb_path, devices_spec=config.get('devices_spec')) self.replications = Tests.is_integer(config.get('replications', 1)) self.paths = config.get('paths', []) self.profilers = Profilers(config.get('profilers', {}), config) monkeyrunner_path = config.get('monkeyrunner_path', 'monkeyrunner') self.scripts = Scripts(config.get('scripts', {}), monkeyrunner_path=monkeyrunner_path) self.time_between_run = Tests.is_integer( config.get('time_between_run', 0)) Tests.check_dependencies(self.devices, self.profilers.dependencies()) self.output_root = paths.OUTPUT_DIR self.result_file_structure = None if restart: for device in self.devices: self.prepare_device(device, restart=True)
def __init__(self, config, progress, restart): super(WebExperiment, self).__init__(config, progress, restart) self.browsers = [ BrowserFactory.get_browser(b)(config) for b in config.get('browsers', ['chrome']) ] Tests.check_dependencies(self.devices, [b.package_name for b in self.browsers]) self.duration = Tests.is_integer(config.get('duration', 0)) / 1000
def __init__(self, path, timeout=0, logcat_regex=None): self.logger = logging.getLogger(self.__class__.__name__) self.path = path self.filename = op.basename(path) if not op.isfile(path): raise FileNotFoundError(self.filename) self.timeout = float(Tests.is_integer(timeout)) / 1000 self.logcat_event = logcat_regex if logcat_regex is not None: self.logcat_event = Tests.is_string(logcat_regex)
def cross_validate_parameters(dataset_name, train_set, test_set): dims = [i for i in range(1, 7)] sigmas = [0.001, 0.01, 0.1, 1, 2, 5] accuracies = [] best_accu_and_dim = 0, 0 max = 0 for dim in dims: clf_poly = Perceptron.Perceptron(dataset_name, train_set[:, :-1], train_set[:, -1], _kernel_=2, epochs=10, _dim_=dim) accuracy, accuracy_index = tests.best_epoch(clf_poly, test_set, 10) # clf_poly.fit() # predicted = clf_poly.predict_set(test_set[:, :-1], test_set[:, -1]) # accuracy = clf_poly.accuracy(test_set[:, -1], predicted) accuracies.append((accuracy, dim)) for accu, dim in accuracies: if accu > max: max = accu best_accu_and_dim = accu, dim accuracies = [] best_accu_and_sigma = 0, 0 max = 0 for sigma in sigmas: clf_gaussian = Perceptron.Perceptron(dataset_name, train_set[:, :-1], train_set[:, -1], _kernel_=3, epochs=10, _sigma_=sigma) accuracy, accuracy_index = tests.best_epoch(clf_gaussian, test_set, 10) # clf_gaussian.fit() # predicted = clf_gaussian.predict_set(test_set[:, :-1], test_set[:, -1]) # accuracy = clf_gaussian.accuracy(test_set[:, -1], predicted) accuracies.append((accuracy, sigma)) for accu, sigma in accuracies: if accu > max: max = accu best_accu_and_sigma = accu, sigma print("Best accuracy with associated dim: ", best_accu_and_dim, "\n", "Best accuracy with associated sigma :", best_accu_and_sigma) return best_accu_and_dim, best_accu_and_sigma
def __init__(self, config): self.package = None self.duration = Tests.is_integer(config.get('duration', 0)) / 1000 super(NativeExperiment, self).__init__(config) for apk in config.get('paths', []): if not op.isfile(apk): raise ConfigError('File %s not found' % apk)
def OnLoad(): MessageWindow = GemRB.LoadWindow(0, GUICommon.GetWindowPack(), WINDOW_BOTTOM|WINDOW_HCENTER) MessageWindow.SetFlags (WF_BORDERLESS|IE_GUI_VIEW_IGNORE_EVENTS, OP_OR) MessageWindow.AddAlias("MSGWIN") MessageWindow.AddAlias("HIDE_CUT", 0) # set up some *initial* text (UpdateControlStatus will get called several times) TMessageTA = MessageWindow.GetControl(0) TMessageTA.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL|IE_GUI_TEXTAREA_HISTORY) TMessageTA.SetResizeFlags(IE_GUI_VIEW_RESIZE_ALL) TMessageTA.AddAlias("MsgSys", 0) TMessageTA.AddAlias("MTA", 0) TMessageTA.SetColor({'r' : 255, 'g' : 0, 'b' : 0}, TA_COLOR_OPTIONS) TMessageTA.SetColor({'r' : 255, 'g' : 255, 'b' : 255}, TA_COLOR_HOVER) results = Tests.RunTests () TMessageTA.SetText ("[cap]D[/cap]emo " + "DEMO "*40 + "\n" + results) PauseButton = MessageWindow.GetControl (2) PauseButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, lambda: GemRB.GamePause (2, 0)) PauseButton.SetAnimation ("loading") PauseButton.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NORMAL, OP_SET) MapButton = MessageWindow.GetControl (3) MapButton.SetText ("M") MapButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, GUIMA.OpenMapWindow) MapButton.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, lambda: GemRB.MoveToArea ("ar0110")) CenterButton = MessageWindow.GetControl (4) CenterButton.SetText ("C") CenterButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, lambda: GemRB.GameControlSetScreenFlags (SF_CENTERONACTOR, OP_OR)) InventoryButton = MessageWindow.GetControl (5) InventoryButton.SetText ("I") InventoryButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, GUIINV.OpenInventoryWindow)
def __init__(self, config): self.logger = logging.getLogger(self.__class__.__name__) self.basedir = None if 'devices' not in config: raise ConfigError('"device" is required in the configuration') adb_path = config.get('adb_path', 'adb') self.devices = Devices(config['devices'], adb_path=adb_path) self.replications = Tests.is_integer(config.get('replications', 1)) self.paths = config.get('paths', []) self.profilers = Profilers(config.get('profilers', {})) monkeyrunner_path = config.get('monkeyrunner_path', 'monkeyrunner') self.scripts = Scripts(config.get('scripts', {}), monkeyrunner_path=monkeyrunner_path) self.time_between_run = Tests.is_integer( config.get('time_between_run', 0)) Tests.check_dependencies(self.devices, self.profilers.dependencies()) self.output_root = paths.OUTPUT_DIR
def long_task(self): """Background task that runs a long function with progress reports.""" Tests.client_code(testOne) message = '' total = random.randint(10, 50) for i in range(total): self.update_state(state='PROGRESS', meta={ 'current': i, 'total': total, 'status': message }) time.sleep(1) return { 'current': 100, 'total': 100, 'status': 'Task completed!', 'result': 42 }
def __init__(self, config): super(Batterystats, self).__init__(config) self.profile = False self.cleanup = config.get('cleanup') # "config" only passes the fields under "profilers", so config.json is loaded again for the fields below config_file = load_json(op.join(paths.CONFIG_DIR, 'config.json')) self.type = config_file['type'] self.systrace = config_file.get('systrace_path', 'systrace') self.powerprofile = config_file['powerprofile_path'] self.duration = Tests.is_integer(config_file.get('duration', 0)) / 1000
def main(argv): parser = argparse.ArgumentParser() parser.add_argument("-t","--translate",type=str,help="translates a Japanese sentence to English and writes it to a file") parser.add_argument("--batch-translate",action="store_true", help="translates each line in a file and writes translations to a file") parser.add_argument("--test",type=str, help="tests translation system using file containing test cases") parser.add_argument("--tt", type=str, help="tests the tokenizing using a file") parser.add_argument("-v","--verbose", action="store_true") parser.add_argument("-i", "--interactive", action="store_true", help="run an interactive version of the system") parser.add_argument("-p", "--paraphrase", action="store_true", help="count translations as correct during testing if they are paraphrases of the gold translation") parser.add_argument("--input", type=str, help="input file for translation", default=None) parser.add_argument("--output", type=str, help="output file for translation", default=None) args = parser.parse_args() Constants.VERBOSE = args.verbose Constants.PARAPHRASE = args.paraphrase if args.interactive: start_interactive() if args.translate: if args.output and args.translate != "": PrintTools.write_to_file(translate(args.translate), args.output) else: print("Please specify text to translate and output file") elif args.batch_translate: if args.input and args.output: batch_translate(args.input, args.output) else: print("Please specify input and output files") elif args.test: Tests.test_translator(args.test) elif args.tt: Tests.test_tokenizer(args.tt) else: print("Incorrect arguments") parser.print_help()
def __init__(self, config): super(Android, self).__init__(config) self.profile = False available_data_points = ['cpu', 'mem'] self.interval = float( Tests.is_integer(config.get('sample_interval', 0))) / 1000 self.data_points = config['data_points'] invalid_data_points = [ dp for dp in config['data_points'] if dp not in set(available_data_points) ] if invalid_data_points: self.logger.warning('Invalid data points in config: {}'.format( invalid_data_points)) self.data_points = [ dp for dp in config['data_points'] if dp in set(available_data_points) ] self.data = [['datetime'] + self.data_points]
def OnLoad(): # global PortraitWindow, OptionsWindow GemRB.GameSetPartySize(MAX_PARTY_SIZE) GemRB.GameSetProtagonistMode(1) GemRB.LoadWindowPack(GUICommon.GetWindowPack()) # GUICommonWindows.PortraitWindow = None # GUICommonWindows.ActionsWindow = None # GUICommonWindows.OptionsWindow = None # ActionsWindow = GemRB.LoadWindow(3) # OptionsWindow = GemRB.LoadWindow(0) # PortraitWindow = GUICommonWindows.OpenPortraitWindow(1) # GemRB.SetVar("PortraitWindow", PortraitWindow.ID) # GemRB.SetVar("ActionsWindow", ActionsWindow.ID) # GemRB.SetVar("OptionsWindow", OptionsWindow.ID) GemRB.SetVar("TopWindow", -1) GemRB.SetVar("OtherWindow", -1) GemRB.SetVar("FloatWindow", -1) GemRB.SetVar("PortraitPosition", 2) #Right GemRB.SetVar("ActionsPosition", 4) #BottomAdded GemRB.SetVar("OptionsPosition", 0) #Left GemRB.SetVar("MessagePosition", 4) #BottomAdded GemRB.SetVar("OtherPosition", 5) #Inactivating GemRB.SetVar("TopPosition", 5) #Inactivating # GUICommonWindows.OpenActionsWindowControls (ActionsWindow) # GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 1, None) ## GUICommon.GameWindow.SetVisible (WINDOW_VISIBLE) UpdateControlStatus() # set up some *initial* text (UpdateControlStatus will get called several times) TMessageTA.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL|IE_GUI_TEXTAREA_HISTORY) results = Tests.RunTests () TMessageTA.SetText ("[cap]D[/cap]emo " + "DEMO "*40 + "\n" + results) print results
def test(dtb_url=default_dtb, schema="Football", market="1x2", margin='basic', csv=True, csvfile="", bookmakers=None): if bookmakers is None: bookmakers = default_bookmakers closed, opening, _, _ = load_data(dtb_url=dtb_url, schema=schema, market=market, to_numpy=False, csv=csv, csv_file=csvfile) if closed is None: return for bookmaker in bookmakers: closed_pom = closed[closed['Bookmaker'] == bookmaker] opening_pom = opening[opening['Bookmaker'] == bookmaker] closed_odds = to_odds(closed_pom, market=market) closed_results = closed_pom['results'] opening_odds = to_odds(opening_pom, market=market) opening_results = opening_pom['results'] test = Tests.Tests(closed_odds=closed_odds, opening_odds=opening_odds, market=market, schema=schema, margin=margin, opening_results=opening_results, closed_results=closed_results, Bookmaker=bookmaker, test_list=config.default_list, txt_path=config.txt_path, pickle_path=config.pickle_path, png_path=config.png_path) test.test() test.save()
def testme(files=None): """ Test function """ import Tests from ROOT import TH1F,TFile if files != None: in1 = TFile( files[0] ) in2 = TFile( files[1] ) hname = "Spectra/hProtonSpectrum" h1=in1.Get( hname ) h2=in2.Get( hname ) print h1,h2 else: h1 = TH1F("h1","h",100,-10,10) h2 = TH1F("h2","h",100,-10,10) h1.FillRandom("gaus") h2.FillRandom("gaus") from ROOT import TCanvas global c c=TCanvas() c.Divide(1,2) c.cd(1) h1.DrawCopy() h2.SetLineColor(2) h2.DrawCopy("same") from Utils import DataType #aTest = Tests.KolmogorovSmirnovTest( h1 , h2 , DataType.BINNED1D) aTest = Tests.Binned1DChi2Test(h1,h2) #print aTest.pval(),aTest.stat() aResult = Output("A-Test") anAlgo = Algorithm( aTest , aResult ) c.cd(2) anAlgo.test.residuals.Draw() anAlgo.test.residuals.Draw() print anAlgo.check() print aResult return h1,h2,anAlgo.test.residuals
def deconstruct_field(original_ff_spectral, kx_array, kz_array, Nm, y, c, Re, baseflow, mean_profile, sparse): ''' Deconstruct given flow field and return the resolvent modes, forcing modes, singular values and amplitude coefficients needed to reconstruct it. ================================================================= INPUTS: ================================================================= original_ff_spectral: 3D array of flow field to approximate in xz spectral form with Chebyshev nodes in wall-normal direction (Chebyshev spacing). Stacked in wall-normal direction: dimensions: (Nx, Nd*Ny, Nz). kx_array: 1D array of streamwise Fourier modes. kz_array: 1D array of spanwise Fourier modes. Nm: Number of interior Chebyshev nodes, i.e. Ny - 2 (endpoints removed). y: Grid points in the wall-normal direction. c: Wavespeed. Re: Reynolds number based on laminar baseflow centreline velocity, i.e. Re = 1 / nu. baseflow: Base flow type: [laminar, Couette], laminar means Plane Poiseuille. mean_profile: 1D array of streamwise velocity profile of the turbulent mean in wall-normal direction, (endpoints included). sparse: Boolean that determines whether to use sparse or full SVD algorithm. ================================================================= OUTPUTS: ================================================================= A dictionary named 'deconstructed_dict' which contains: resolvent_modes: 4D array of resolvent modes at each Fourier mode combination: resolvent_modes[mx, mz, :, :] gives column vectors of given rank, i.e. rank = resolvent_modes.shape[3]. forcing_modes: 4D array of forcing modes at each Fourier mode combination:= resolvent_modes[mx, mz, :, :] gives column vectors of given rank, i.e. rank = resolvent_modes.shape[3]. singular_values: 3D array of singular values at each Fourier mode combination: singular_values[mx, mz, :] gives 1D array of singular values, where rank = len(singular_values[mx, mz, :]). coefficients: 3D array of complex amplitude coefficients at each Fourier mode combination: coefficients[mx, mz, :] gives 1D array of coefficients, where rank = len(coefficients[mx, mz, :]). ''' #===============================================================# #### Store the resolvent modes and amplitude coefficients #### # at each Fourier mode pair # #===============================================================# resolvent_modes_array = np.zeros((len(kx_array), len(kz_array), 3*Nm, 3*Nm), dtype=complex) forcing_modes_array = np.zeros((len(kx_array), len(kz_array), 3*Nm, 3*Nm), dtype=complex) coefficients_array = np.zeros((len(kx_array), len(kz_array), 3*Nm), dtype=complex) sing_vals_array = np.zeros((len(kx_array), len(kz_array), 3*Nm), dtype=float) #===============================================================# #### Calculate differentiation matrices and mean flow derivatives #===============================================================# chebyshev_differentiation, mean_flow_derivatives = ps.calculate_derivatives(Nm+2, mean_profile, baseflow) #===============================================================# #### Loop through wavenumbers #### #===============================================================# startTime = datetime.now() for mx in range(0, len(kx_array)): kx = kx_array[mx] # print('\nkx:'+ str(kx)) for mz in range(0, len(kz_array)): kz = kz_array[mz] # sys.stdout.write(".") # sys.stdout.flush() if kx == 0 and kz == 0: # Zeroth Fourier modes resolvent_modes_array[mx, mz, :, 0] = original_ff_spectral[mx, :, mz] continue # Start the loop again #-------------------------------------------------------- #### Calculate the state vectors - #-------------------------------------------------------- omega = kx * c wegihted_transfer_function, w = ps.calculate_transfer_function(kx, kz, Re, Nm, omega, chebyshev_differentiation, mean_flow_derivatives) #-------------------------------------------------------- #### Perform SVD - #-------------------------------------------------------- if sparse: weighted_resolvent_modes, singular_values, weighted_forcing_modes = svd(wegihted_transfer_function, full_matrices=False) else: weighted_resolvent_modes, singular_values, weighted_forcing_modes = svd(wegihted_transfer_function) #-------------------------------------------------------- #### Test: SVD - #-------------------------------------------------------- Tests.SVD(weighted_resolvent_modes, singular_values, weighted_forcing_modes, wegihted_transfer_function, sparse) #-------------------------------------------------------- #### Test: Orthogonality - #-------------------------------------------------------- Tests.orthogonality(weighted_resolvent_modes) Tests.orthogonality(weighted_forcing_modes) #-------------------------------------------------------- #### Test: Invertibility - #-------------------------------------------------------- Tests.invertible(np.diag(singular_values)) #-------------------------------------------------------- #### Retrieve non-grid-weighted (physical) modes - #-------------------------------------------------------- weighted_resolvent_modes = np.asmatrix(weighted_resolvent_modes) weighted_forcing_modes = np.asmatrix(weighted_forcing_modes) resolvent_modes = np.linalg.solve(w, weighted_resolvent_modes) forcing_modes = np.linalg.solve(w, weighted_forcing_modes) #-------------------------------------------------------- #### Tests: Continuity condition - #-------------------------------------------------------- Tests.continuity(resolvent_modes, np.diag(singular_values), kx, kz, Nm, chebyshev_differentiation['D1']) #-------------------------------------------------------- #### Fix phase of resolvent modes - # based on critical layer or centreline - #-------------------------------------------------------- phase_shift = np.zeros((resolvent_modes.shape[1], resolvent_modes.shape[1]), dtype=np.complex128) ind0 = Nm/2 + 1 # Use centreline, unless if c < 1.0: inds = Tests.indices(mean_flow_derivatives['U'].diagonal(), lambda x: x > c) if len(inds) > 0: ind0 = inds[0] np.fill_diagonal(phase_shift, np.exp(-1j * np.angle(resolvent_modes[ind0,:]))) resolvent_modes *= phase_shift #-------------------------------------------------------- #### Project resolvent modes to get coefficients - #-------------------------------------------------------- # Initialize amplitude coefficients vector xi = np.zeros((3*Nm, 1), dtype=complex) # Projection xi = inv(np.diag(singular_values)) * resolvent_modes.H * w.H * w * np.asmatrix(original_ff_spectral[mx, :, mz]).T Tests.projection(xi, np.diag(singular_values), resolvent_modes, np.asmatrix(original_ff_spectral[mx, :, mz]).T, 1e-10) #-------------------------------------------------------- #### Store resolvent modes, singular values and coeffs. - #-------------------------------------------------------- resolvent_modes_array[mx, mz, :, :] = resolvent_modes forcing_modes_array[mx, mz, :, :] = forcing_modes coefficients_array[mx, mz, :] = np.squeeze(np.asarray(xi)) sing_vals_array[mx, mz, :] = singular_values calcTime = datetime.now() - startTime # print("\n\n\n") # print(calcTime) # print("\n\n\n") deconstructed_dict = {} deconstructed_dict['resolvent_modes'] = resolvent_modes_array deconstructed_dict['forcing_modes'] = forcing_modes_array deconstructed_dict['singular_values'] = sing_vals_array deconstructed_dict['coefficients'] = coefficients_array return deconstructed_dict
ff.x, ff.y, ff.velocityField[i, :, :, j].T, ":", ":", format(ff.z[j], '.2f'), ff.Re, "-", "-", str(j), ff.velocityField[m, :, :, j].T, ff.velocityField[p, :, :, j].T, "x", "y", velName, vl_max, vl_min, args.Quiver, contour_levels, printFullTitle, args.Small, args.Type) #===================================================================# #### If Co-Ordinate given #### #===================================================================# printFullTitle = True if args.Coordinate: if n == 0: coords = Tests.indices(ff.x, lambda m: m > float(args.Coordinate)) x_coord = coords[0] x_directory = ut.make_Folder(images_directory, "x", False) ut.plot_Contour(x_directory, str(args.File[:-3]), ff.z, ff.y, ff.velocityField[i, x_coord, :, :], format(ff.x[x_coord], '.2f'), ":", ":", ff.Re, str(x_coord), "-", "-", ff.velocityField[m, x_coord, :, :], ff.velocityField[p, x_coord, :, :], "z", "y", velName, vl_max, vl_min, args.Quiver, contour_levels, printFullTitle, args.Small, args.Type) elif n == 1: coords = Tests.indices(ff.y, lambda m: m > float(args.Coordinate)) y_coord = coords[-1]
def test(self): r = jsonpickle.encode(Tests.testear(), unpicklable=False) return json.loads(r)
def OnTest(self, event): import Tests Tests.test_wxFrame(self)
def resolvent_formulation(ff): #===============================================================# #### Initialize 3D array to store approximated velocity field ### #===============================================================# # Velocity field is stacked in the wall-normal direction. tmp = np.zeros((ff.Nx, ff.Nd*ff.Nm, ff.Nz), dtype=complex) # Note that the number of gridpoints in the wall-normal direction # are equal to the number of interior Chebyshev nodes. This is # becasue when reshaped, the velocity field is missing its # wall-boundaries, i.e. top and bottom xz-planes. #===============================================================# #### Calculate differentiation matrices and mean flow derivatives #===============================================================# chebyshev_differentiation, mean_flow_derivatives = ps.calculate_derivatives(ff.Ny, [], ff.baseflow) #===============================================================# #### Loop through Wavepacket #### #===============================================================# for triplet in range(0, len(ff.kx)): #===========================================================# #### Get fundamental wavenumbers from Wavepacket #### #===========================================================# fund_alpha = ff.kx[triplet] fund_beta = ff.kz[triplet] amplitude = ff.chi_tilde[triplet] #===========================================================# #### Calculate first Fourier modes #### #===========================================================# kx_array = fund_alpha * ff.Mx kz_array = fund_beta * ff.Mz #===========================================================# #### Loop through the Fourier modes #### #===========================================================# for mx in range(0, len(kx_array)): kx = kx_array[mx] # Streamwise Fourier mode for mz in range(0, len(kz_array)): kz = kz_array[mz] # Spanwise Fourier mode if kx == 0 or kz == 0: continue print('kx:\t'+ str(kx) + "\tkz:\t" + str(kz)) #---------------------------------------------------- #### Calculate the state vectors - #---------------------------------------------------- omega = kx * ff.c wegihted_transfer_function, w = ps.calculate_transfer_function(kx, kz, ff.Re, ff.Nm, omega, chebyshev_differentiation, mean_flow_derivatives) #---------------------------------------------------- #### Perform SVD - #---------------------------------------------------- weighted_resolvent_modes, singular_values, weighted_forcing_modes = svd(wegihted_transfer_function) #---------------------------------------------------- #### Test: SVD - #---------------------------------------------------- Tests.SVD(weighted_resolvent_modes, singular_values, weighted_forcing_modes, wegihted_transfer_function, False) #---------------------------------------------------- #### Test: Orthogonality - #---------------------------------------------------- Tests.orthogonality(weighted_resolvent_modes) Tests.orthogonality(weighted_forcing_modes) #---------------------------------------------------- #### Test: Invertibility - #---------------------------------------------------- Tests.invertible(np.diag(singular_values)) #---------------------------------------------------- #### Retrieve non-grid-weighted (physical) modes - #---------------------------------------------------- weighted_resolvent_modes = np.asmatrix(weighted_resolvent_modes) weighted_forcing_modes = np.asmatrix(weighted_forcing_modes) resolvent_modes = np.linalg.solve(w, weighted_resolvent_modes) forcing_modes = np.linalg.solve(w, weighted_forcing_modes) #---------------------------------------------------- #### Test: Continuity condition - #---------------------------------------------------- Tests.continuity(resolvent_modes, np.diag(singular_values), kx, kz, ff.Nm, chebyshev_differentiation['D1']) #---------------------------------------------------- #### Fix phase of resolvent modes - # based on critical layer or centreline - #---------------------------------------------------- phase_shift = np.zeros((resolvent_modes.shape[1], resolvent_modes.shape[1]), dtype=np.complex128) ind0 = ff.Nm/2 + 1 # Use centreline, unless if ff.c < 1.0: inds = Tests.indices(mean_flow_derivatives['U'].diagonal(), lambda x: x > ff.c) if len(inds) > 0: ind0 = inds[0] np.fill_diagonal(phase_shift, np.exp(-1j * np.angle(resolvent_modes[ind0,:]))) resolvent_modes *= phase_shift # Alternative Method: # # Non-weighted forcing modes (physical forcing modes) # unweighted_forcing_modes = np.linalg.solve(state_vecs['w'], forcing_modes_h.conjugate().T) # unweighted_forcing_modes *= phase_shift # unweighted_H = np.linalg.inv(state_vecs['w']) * state_vecs['H'] * state_vecs['w'] # unweighted_vel_modes = unweighted_H * unweighted_forcing_modes * np.diag(1.0/singular_values) # delta_r = unweighted_vel_modes.real - resolvent_modes.real # delta_i = unweighted_vel_modes.imag - resolvent_modes.imag #---------------------------------------------------- #### Calculate spectral velocity vector - # u_tilde = psi * sigma * xi - # u_tilde = psi * chi - #---------------------------------------------------- u_tilde = resolvent_modes[:, 0] * amplitude # Rank 1 #---------------------------------------------------- # Inverse fourier transform - #---------------------------------------------------- u_tilde = np.asmatrix(u_tilde) physical_ff = np.zeros((ff.Nx, ff.Nd*ff.Nm, ff.Nz), dtype=complex) physical_ff = ps.my_ifft(u_tilde, kx, kz, ff) tmp += physical_ff return tmp
print("COMMON: ") print(common) print("UNCOMMON: ") print(uncommon) print("ZEROS: ") print(zeros) analyzeKenoData.checkNums(testFile, maxDraw, 10, uncommon[:3]) #Run test proven in 3 with if trigger == 4: testFolder = 'kenoData/kenoNum01-2015' print("Testing with " + testFolder) #f_count = 0 #t_count = 0 for filename in os.listdir(testFolder): fullPath = (testFolder+'/'+filename) earnings = Tests.test4(fullPath, 4) print("EARNINGS: " + str(earnings)) ''' if(Tests.test3(fullPath)): t_count+=1 else: f_count+=1 print("TRUE: "+ str(t_count)) print("FALSE: " + str(f_count)) ''' #Step 1: Get Data from MA Keno site #Get Yesterday's URL ''' today = date.today()
def run(): """ Get Test suite and run it """ suite = Tests.suite() TextTestRunner(verbosity = 2 ).run(suite)
#================================================================ ff_original = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], file_info['ff'], "pp") Tests.fft_ifft(ff_original) #================================================================ #### Check velocity profile #================================================================ # Create empty 4D array to store mean flow field mean = np.zeros((file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'])) mean_profile = [] if args.MeanProfile: # Velocity profile given #------------------------------------------------ #### Read velocity profile vel_profile = ut.read_Vel_Profile(parent_directory, args.MeanProfile) # Check to see if it is a mean profile or a deviation profile. deviation = any(n < 0 for n in vel_profile)
def main(File, Details, VelComponent, SpatialComponent, Coordinate, Full, SpatiallyAveraged, Quiver, Levels): #===================================================================# #### Format current directory path #### #===================================================================# pwd = ut.format_Directory_Path(os.getcwd()) #===================================================================# #### Read file and details file #### #===================================================================# file_info, original_attrs = ut.read_H5(File) details = ut.read_Details(Details) #===================================================================# #### Make output directory for images and change into it #### #===================================================================# images_directory = ut.make_Folder(pwd, "images_" + str(File)[:-3], False) os.chdir(images_directory) #===================================================================# #### Initialise flow field class with given file #### #===================================================================# ff = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], file_info['ff'], "pp") #===================================================================# #### Set velocity and spatial components #### #===================================================================# i = VelComponent n = SpatialComponent m=n+1; p=n-1 if m==3: m=0 if p==-1: p=2 velName = "" if i==0: velName = "u" elif i==1: velName = "v" elif i==2: velName = "w" #===================================================================# #### Start plotting #### #===================================================================# print("Plotting...") vl_max = np.amax(ff.velocityField[i, :, :, :]) vl_min = np.amin(ff.velocityField[i, :, :, :]) printFullTitle = True if Levels: contour_levels = Levels else: contour_levels = 20 #===================================================================# #### If Full selected #### #===================================================================# if Full: if n == 0: x_directory = ut.make_Folder(images_directory, "x", False) for j in range(0, ff.Nx): ut.plot_Contour(x_directory, str(File[:-3]), ff.z, ff.y, ff.velocityField[i, j, :, :], format(ff.x[j], '.2f'), ":", ":", ff.Re, str(j), "-", "-", ff.velocityField[m, j, :, :], ff.velocityField[p, j, :, :], "z", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 1: y_directory = ut.make_Folder(images_directory, "y", False) for j in range(0, ff.Ny): ut.plot_Contour(y_directory, str(File[:-3]), ff.z, ff.x, ff.velocityField[i, :, j, :], ":", format(ff.y[j], '.2f'), ":", ff.Re, "-", str(j), "-", ff.velocityField[m, :, j, :], ff.velocityField[p, :, j, :], "z", "x", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 2: z_directory = ut.make_Folder(images_directory, "z", False) for j in range(0, ff.Nz): ut.plot_Contour(z_directory, str(File[:-3]), ff.x, ff.y, ff.velocityField[i, :, :, j].T, ":", ":", format(ff.z[j], '.2f'), ff.Re, "-", "-", str(j), ff.velocityField[m, :, :, j].T, ff.velocityField[p, :, :, j].T, "x", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) #===================================================================# #### If Co-Ordinate given #### #===================================================================# printFullTitle = True if Coordinate: if n == 0: coords = Tests.indices(ff.x, lambda m: m > float(Coordinate)) x_coord = coords[0] x_directory = ut.make_Folder(images_directory, "x", False) ut.plot_Contour(x_directory, str(File[:-3]), ff.z, ff.y, ff.velocityField[i, x_coord, :, :], format(ff.x[x_coord], '.2f'), ":", ":", ff.Re, str(x_coord), "-", "-", ff.velocityField[m, x_coord, :, :], ff.velocityField[p, x_coord, :, :], "z", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 1: coords = Tests.indices(ff.y, lambda m: m > float(Coordinate)) y_coord = coords[-1] y_directory = ut.make_Folder(images_directory, "y", False) ut.plot_Contour(y_directory, str(File[:-3]), ff.z, ff.x, ff.velocityField[i, :, y_coord, :], ":", format(ff.y[y_coord], '.2f'), ":", ff.Re, "-", str(y_coord), "-", ff.velocityField[m, :, y_coord, :], ff.velocityField[p, :, y_coord, :], "z", "x", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 2: coords = Tests.indices(ff.z, lambda m: m > float(Coordinate)) z_coord = coords[0] z_directory = ut.make_Folder(images_directory, "z", False) ut.plot_Contour(z_directory, str(File[:-3]), ff.x, ff.y, ff.velocityField[i, :, :, z_coord].T, ":", ":", format(ff.z[z_coord], '.2f'), ff.Re, "-", "-", str(z_coord), ff.velocityField[m, :, :, z_coord].T, ff.velocityField[p, :, :, z_coord].T, "x", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) #===================================================================# #### If Spatially averaging selected #### #===================================================================# printFullTitle = False if SpatiallyAveraged: if n == 0: # Average the flow field in teh streamwise direction. x_averaged_ff = np.zeros((ff.Nd, ff.Ny, ff.Nz)) for nd in range(0, ff.Nd): for nx in range(0, ff.Nx): x_averaged_ff[nd, :, :] += ff.velocityField[nd, nx, :, :] x_averaged_ff *= (1.0 / ff.Nx) vl_max = np.amax(x_averaged_ff[i, :, :]) vl_min = np.amin(x_averaged_ff[i, :, :]) fileName = str(File)[:-3] + "_x_avgd_" ut.plot_Contour(images_directory, fileName, ff.z, ff.y, x_averaged_ff[i, :, :], "avg", ":", ":", ff.Re, "x-avg", "-", "-", x_averaged_ff[m, :, :], x_averaged_ff[p, :, :], "z", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 1: # Average the flow field in teh streamwise direction. y_averaged_ff = np.zeros((ff.Nd, ff.Nx, ff.Nz)) for nd in range(0, ff.Nd): for ny in range(0, ff.Ny): y_averaged_ff[nd, :, :] += ff.velocityField[nd, :, ny, :] y_averaged_ff *= (1.0 / ff.Ny) vl_max = np.amax(y_averaged_ff[i, :, :]) vl_min = np.amin(y_averaged_ff[i, :, :]) fileName = str(File)[:-3] + "_y_avgd_" ut.plot_Contour(images_directory, fileName, ff.z, ff.x, y_averaged_ff[i, :, :], ":", "avg", ":", ff.Re, "-", "y-avg", "-", y_averaged_ff[m, :, :], y_averaged_ff[p, :, :], "z", "x", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) elif n == 2: # Average the flow field in teh streamwise direction. z_averaged_ff = np.zeros((ff.Nd, ff.Nx, ff.Ny)) for nd in range(0, ff.Nd): for nz in range(0, ff.Nz): z_averaged_ff[nd, :, :] += ff.velocityField[nd, :, :, nz] z_averaged_ff *= (1.0 / ff.Nz) vl_max = np.amax(z_averaged_ff[i, :, :]) vl_min = np.amin(z_averaged_ff[i, :, :]) fileName = str(File)[:-3] + "_z_avgd_" ut.plot_Contour(images_directory, fileName, ff.x, ff.y, z_averaged_ff[i, :, :].T, ":", ":", "avg", ff.Re, "-", "-", "z-avg", z_averaged_ff[m, :, :].T, z_averaged_ff[p, :, :].T, "x", "y", velName, vl_max, vl_min, Quiver, contour_levels, printFullTitle) ut.print_EndMessage()
'switches': SYS.BPM.switches, 'switch_val': SYS.BPM.switch_val, 'attenuation': SYS.BPM.attn, 'dsc': SYS.BPM.dsc, 'kx': SYS.BPM.kx, 'ky': SYS.BPM.ky } with open(subdirectory + "initial_BPM_state.json", 'w') as write_file: json.dump(data_out, write_file) Tests.beam_position_equidistant_grid_raster_scan_test( test_system_object=SYS, rf_frequency=dls_RF_frequency, power_level=-40, nominal_attenuation=10, x_points=3, y_points=3, settling_time=settling_time, sub_directory=subdirectory) Tests.beam_power_dependence(test_system_object=SYS, frequency=dls_RF_frequency, power_levels=np.arange(-40, -100, -10), settling_time=settling_time, sub_directory=subdirectory) # Tests.fixed_voltage_amplitude_fill_pattern_test(test_system_object=SYS, # frequency=dls_RF_frequency, # max_power=-40, # duty_cycles=np.arange(1, 0, -0.1),
def main(File, Rank, Directory, MeanProfile, Sparse, Testing): #================================================================ #### Check file type #================================================================ if File[-3:] == ".h5": print("HDF5 file given.") #------------------------------------------------------------ #### Read the HDF5 and details file #------------------------------------------------------------ file_info, original_attrs = ut.read_H5(File) details = ut.read_Details("eq1_Details.txt") #------------------------------------------------------------ #### Copy geometry file into rank-temp #------------------------------------------------------------ command = "field2ascii ../" + str(File) + " " + str(File)[:-3] os.system(command) elif File[-3:] == ".ff": #------------------------------------------------------------ #### Convert the binary file to ascii #------------------------------------------------------------ command = "field2ascii -p ../" + str(File) + " " + str(File)[:-3] print(command) os.system(command) #------------------------------------------------------------ #### Read ASCII file and details file #------------------------------------------------------------ file_info = ut.read_ASC_channelflow("", str(File)[:-3]) details = ut.read_Details("", "u0_Details.txt") elif File[-3:] == "asc": #------------------------------------------------------------ #### Read ASCII file and details file #------------------------------------------------------------ file_info = ut.read_ASC_PP("", str(File)[:-7]) details = ut.read_Details("", "u0_Details.txt") else: # No file type given. ut.error("Invalid file given.") #================================================================ #### Initialise flow field object for field (to approximate) #================================================================ ff_original = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], file_info['ff'], "pp") Tests.fft_ifft(ff_original) #================================================================ #### Check velocity profile #================================================================ # Create empty 4D array to store mean flow field mean = np.zeros((file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'])) mean_profile = [] if MeanProfile: # Velocity profile given #------------------------------------------------------------ #### Read velocity profile #------------------------------------------------------------ vel_profile = ut.read_Vel_Profile("", MeanProfile) # Check to see if it is a mean profile or a deviation profile. deviation = any(n < 0 for n in vel_profile) if deviation: # Deviation profile given # Add baseflow to deviation baseflow = [] if details['bf'] == "lam": # Laminary base flow baseflow = 1.0 - ff_original.y**2.0 elif details['bf'] == "cou": # Couette base flow baseflow = ff_original.y # Add baseflow to deviation to get turbulent mean profile mean_profile = vel_profile + np.asarray(baseflow) else: # Turbulent mean profile given mean_profile = vel_profile #------------------------------------------------------------ #### Construct 4D array from mean_profile #------------------------------------------------------------ mean = ut.make_ff_from_profile(vel_profile, ff_original.Nd, ff_original.Nx, ff_original.Nz) else: #------------------------------------------------------------ #### Use base flow only #------------------------------------------------------------ # Add baseflow to deviation baseflow = [] if details['bf'] == "lam": # Laminary base flow baseflow = 1.0 - ff_original.y**2.0 elif details['bf'] == "cou": # Couette base flow baseflow = ff_original.y #------------------------------------------------------------ #### Construct 4D array from mean_profile #------------------------------------------------------------ mean = ut.make_ff_from_profile(np.asarray(baseflow), ff_original.Nd, ff_original.Nx, ff_original.Nz) #================================================================ #### Initialize mean flow field object #================================================================ ff_mean = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], mean, "pp") #================================================================ #### ---- Remove the wall boundaries #================================================================ # Removing the xz-planes at y=1 and y=-1, # so that the chebyshev nodes can be used to construct # the transfer function. ff_original.remove_wall_boundaries() ff_mean.remove_wall_boundaries() #================================================================ #### ---- Fourier transform in xz directions #================================================================ ff_original.make_xz_spectral() ff_mean.make_xz_spectral() #================================================================ #### ---- Stack velocity fields in the wall-normal direction #================================================================ ff_original.stack_ff_in_y() ff_mean.stack_ff_in_y() #================================================================ #### Create arrays of Fourier modes to use #================================================================ # Modes multiplied with fundamental wavenumbers #(Modes: the physical modes, i.e. the grid points) kx_array = ff_original.Mx * ff_original.alpha kz_array = ff_original.Mz * ff_original.beta # Tests.checkHermitianSymmetry(ff_original.velocityField[:,0:ff_original.numModes,:], # ff_original.Nx, # ff_original.Nz) # Tests.checkHermitianSymmetry(ff_original.velocityField[:,ff_original.numModes:ff_original.numModes*2,:], # ff_original.Nx, # ff_original.Nz) # Tests.checkHermitianSymmetry(ff_original.velocityField[:,2*ff_original.numModes:ff_original.numModes*3,:], # ff_original.Nx, # ff_original.Nz) #================================================================ #### Ensure valid rank is specified #================================================================ rank = min(Rank, 3*ff_original.numModes) #### -!-!- TESTING -!-!-: Zeroth mode differences if MeanProfile: spectral_mean_profile = np.zeros((3*ff_original.numModes),dtype=complex) mean_profile_sp = np.fft.fft(mean_profile) spectral_mean_profile[1:ff_original.numModes] = mean_profile_sp[1:ff_original.numModes] origFF = ff_original.velocityField[0, :, 0] diffs = spectral_mean_profile - origFF diffsn = np.linalg.norm(diffs) # print("%.2E" % diffsn) #### -!-!- TESTING -!-!-: Synthesizing a Fourier domain flow field # fake_field = ff_original.velocityField ## fake_field *= 0.0+0.0j ## fake_field[1,:,1] += 1.0+2.0j ## fake_field[1,:,-1] += 1.0-2.0j # #================================================================ #### Deconstruct original flow field #================================================================ deconstructed_field = cr.test_deconstruct_field(ff_original.velocityField, kx_array, kz_array, ff_original.numModes, ff_original.y, ff_original.c, ff_original.Re, ff_original.baseflow, mean_profile, Sparse) #================================================================ #### Reconstruct approximated flow field #================================================================ approximated_ff_spectral = cr.test_construct_field(deconstructed_field['resolvent_modes'], deconstructed_field['singular_values'], deconstructed_field['coefficients'], kx_array, kz_array, ff_original.numModes, rank, mean_profile, ff_original.baseflow, ff_original.y) #### -!-!- TESTING -!-!-: Synthesizing a Fourier domain flow field # The retrieved field should be the same as the fak_field... retrieved_difference = approximated_ff_spectral - ff_original.velocityField retrieved_difference_n = np.linalg.norm(retrieved_difference) #================================================================ #### Initialize approximated flow field object #================================================================ ff_approximated = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], ff_original.numModes, # the velocity field is missing wall boundaries file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], approximated_ff_spectral, "sp") # If not symmetric: you need to filter the negative frequencies in the approximated result. # This will introduce hermitian symmetry. #================================================================ #### ---- Unstack velocity fields in the wall-normal direction #================================================================ ff_approximated.unstack_ff() ff_mean.unstack_ff() ff_original.unstack_ff() #================================================================ #### ---- Inverse Fourier transform approximated and mean velocity fields in xz directions #================================================================ ff_approximated.make_xz_physical() ff_mean.make_xz_physical() ff_original.make_xz_physical() #================================================================ #### ---- Add wall boundaries #================================================================ ff_approximated.add_wall_boundaries() ff_mean.add_wall_boundaries() ff_original.add_wall_boundaries() #================================================================ #### Remove mean flow from approximated field (if mean used to reconstruct) #================================================================ # approximated_field = ff_approximated.velocityField.real - ff_mean.velocityField.real # ff_approximated.set_ff(approximated_field, "pp") # # difference = np.linalg.norm(approximated_field - ff_approximated.velocityField) #### -!-!- TESTING -!-!-: Full-Rank decomposition and recomposition: (Real Domain) u_a = ff_approximated.velocityField[0,:,:,:].real u_o = ff_original.velocityField[0,:,:,:].real difference = np.linalg.norm(ff_original.velocityField.real - ff_approximated.velocityField.real) print("") print("The norm of the difference is " + str(difference)) print("") #### -!-!- TESTING -!-!-: Projections if Testing: #### Remove boundaries ff_approximated.remove_wall_boundaries() #### FFT ff_approximated.make_xz_spectral() #### stack in y ff_approximated.stack_ff_in_y() #### Deconstruct the approximated flow field. deconstructed_approximated = cr.deconstruct_field(ff_approximated.velocityField, kx_array, kz_array, ff_approximated.numModes, ff_approximated.c, ff_approximated.Re, ff_approximated.baseflow, rank, mean_profile, Sparse, False) #### Reconstruct projected approximated flow field. doubly_approximated_ff_spectral = cr.construct_field( deconstructed_approximated['resolvent_modes'], deconstructed_approximated['singular_values'], deconstructed_approximated['coefficients'], # ff_mean.velocityField, kx_array, kz_array, ff_approximated.numModes) #### Initialize projected approximated flow field object. ff_doubly_approximated = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], ff_approximated.numModes, # the velocity field is missing wall boundaries file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], doubly_approximated_ff_spectral, "sp") #### unstack ff_doubly_approximated.unstack_ff() ff_approximated.unstack_ff() #### IFFT ff_doubly_approximated.make_xz_physical() ff_approximated.make_xz_physical() #### add wall boundaries ff_doubly_approximated.add_wall_boundaries() ff_approximated.add_wall_boundaries() #### check differences between modes/sing vals/coeffs del_sigma = deconstructed_approximated['singular_values'] - deconstructed_field['singular_values'] del_sigmaR = del_sigma.real del_sigmaI = del_sigma.imag del_sigma_n = np.linalg.norm(del_sigma) print("\n\n||sigma_tilde - sigma|| = " + str(del_sigma_n)) del_psi = deconstructed_approximated['resolvent_modes'] - deconstructed_field['resolvent_modes'] del_psiR = del_psi.real del_psiI = del_psi.imag del_psi_n = np.linalg.norm(del_psi) print("\n\n||psi_tilde - psi|| = " + str(del_psi_n)) del_xi = deconstructed_approximated['coefficients'] - deconstructed_field['coefficients'] del_xiR = del_xi.real del_xiI = del_xi.imag del_xi_n = np.linalg.norm(del_xi) print("\n\n||xi_tilde - xi|| = " + str(del_xi_n)) del_ff = ff_doubly_approximated.velocityField.real - ff_approximated.velocityField.real dim_a = ff_approximated.velocityField.shape print("\nDimension of approximated ff: " + str(dim_a)) dim_da = ff_doubly_approximated.velocityField.shape print("\nDimension of doubly approximated ff: " + str(dim_da)) del_ff_n = np.linalg.norm(del_ff) print("\n\n||u_tilde_tilde - u_tilde|| = " + str(del_ff_n)) #================================================================ #### Create a folder to store the approximated velocity field in #================================================================ os.chdir(parent_directory) # Go up one directory rank_folder = File[:-3]+"_rank_" + str(rank) + "/" rank_folder = parent_directory + rank_folder #if a rank directory does exist, delete it: if os.path.exists(rank_folder): command = "rm -rf " + rank_folder os.system(command) #if a rank directory doesn't exist, create one: if not os.path.exists(rank_folder): os.mkdir(rank_folder) # Change into the new rank directory os.chdir(rank_folder) #================================================================ #### Save flow field to file #================================================================ # Check file type if File[-3:] == ".h5": #------------------------------------------------------------ # Write the file to disk in H5 format #------------------------------------------------------------ fileName = File[:-3] + "_rnk_" + str(rank) ut.write_ASC(ff_approximated, rank_folder, fileName) #------------------------------------------------------------ # Write binary file #------------------------------------------------------------ command = "ascii2field -p false -ge ../rank-temp/" + str(File)[:-3] + ".geom " + fileName + ".asc " + fileName + ".h5" print(command) os.system(command) elif File[-3:] == ".ff": #------------------------------------------------------------ # Write physical ascii file #------------------------------------------------------------ fileName = File[:-3] + "_rnk_" + str(rank) ut.write_ASC(ff_approximated, rank_folder, fileName) #------------------------------------------------------------ # Write binary file #------------------------------------------------------------ command = "ascii2field -p false -ge ../rank-temp/" + str(File)[:-3] + ".geom " + fileName + ".asc " + fileName + ".ff" print(command) os.system(command) elif File[-3:] == "asc": #------------------------------------------------------------ # Write physical ascii file #------------------------------------------------------------ fileName = File[:-3] + "_rnk_" + str(rank) ut.write_ASC_Py(ff_approximated, rank_folder, fileName) #================================================================ #### Write decomposed flow field to HDF5 object. #================================================================ fileName = File[:-3] + "_coeffs" ut.write_amplitude_coefficients(ff_approximated, rank_folder, fileName, deconstructed_field['coefficients']) ut.write_Deconstructed_Field(deconstructed_field, ff_approximated, parent_directory, File[:-3]) #================================================================ # Remove ascii file and temporary folder #================================================================ # os.system("rm *.asc") os.chdir(parent_directory) # command = "rm -rf " + temp_rank_folder # os.system(command) print("\nFinished")
from scripts import PharaohConvert from src import Constants import Tests import PrintTools convert = PharaohConvert.get_alignments() sentences = Tests.read_test_data( r"/home/nikolaj/PycharmProjects/LitteralJapaneseTranslation/data/sentences_dev.txt" ) sentences = Tests.merge_word_endings(sentences) scores = [] i = 1 for sentence in sentences: system = [(k, v) for k, v in convert.get(i).items()] gold = sentence.tokens score = Tests.translation_sentence_score(gold, system) PrintTools.print_translated_sentence(sentence, system, gold, score) scores.append(Tests.TranslationScore(len(gold), score)) i += 1 avg = Tests.TranslationScore.make_average(scores) print("#### average result (Levenshtein distance) ####") avg.print()
data = client.post(request, headers) # print(json.dumps(data, indent=4)) return data ################ # Main Program ################ if __name__ == "__main__": # check program usage if len(sys.argv) < 2: print("Usage: Bitfinex.py key.txt\n") print("key.txt format:") print("LINE 1: public key") print("LINE 2: private key") exit() # TICKER: get IOTA/USD pair state #data = b.get(url) #print(json.dumps(data, indent=4)) # passing bitfinex obj to test module T.run_tests()
import pygame import Tests as RN import variables as var import numpy as np ancho = 700 alto = 500 if __name__ == "__main__": #----------------Inicio---------------- pygame.init() RN.iniciar() pantalla = pygame.display.set_mode([ancho, alto]) fin = False #------------------------------------------------ Tancho = ancho / 2 en_x = 85 en_y = 150 for elemento_vertical in range(len(var.segmentos_verticales)): var.segmentos_verticales[elemento_vertical].rect.x = en_x var.segmentos_verticales[elemento_vertical].rect.y = en_y if elemento_vertical < 1: en_y += 105 elif (elemento_vertical >= 1 and elemento_vertical < 2): en_x += 120 else: en_y -= 105 #-----------------------------------------------------
import LiteralJapanese import Tests from Similarity import init_similarity import Dictionary import Equality import Translator from Grammar import Grammar sentences = Tests.read_test_data( r"C:\Users\Nikolaj\PycharmProjects\LitteralJapaneseTranslation\data\sentences_dev.txt" ) init_similarity() wrong_def = 0 wrong_word = 0 particle_error = 0 other = 0 for sentence in sentences: system = LiteralJapanese.translate(sentence.japanese, translation=sentence.english) gold = sentence.tokens min_len = min(len(system), len(gold)) for i in range(min_len - 1): s_token = system[i] g_token = gold[i] if s_token.japanese == g_token.japanese: is_particle = False if s_token.token.grammar == Grammar.PARTICLE: is_particle = True if not Equality.equals(
ff1.make_xz_spectral() ff2.make_xz_spectral() #===================================================================# #### ---- Stack velocity fields in the wall-normal direction #### #===================================================================# ff1.stack_ff_in_y() ff2.stack_ff_in_y() #===================================================================# #### Calculate amplitude/phase difference #### #===================================================================# tolerance = 1e-9 print("==========================================") print("Differences between " + args.File1[:-3] + " and " + args.File2[:-3]) print("==========================================") message = "Amplitude difference between " + args.File1[:-3] + " and " + args.File2[:-3] diff_A = Tests.difference(abs(ff1.velocityField), abs(ff2.velocityField), tolerance, message) diff_P = mean(angle(ff1.velocityField,deg=True) - angle(ff2.velocityField,deg=True)) print("Amplitude diff \t\t%.2E" % diff_A) print("") print("Field 1 (deg) \t\t%.6f (avg)" % mean(angle(ff1.velocityField,deg=True))) print("Field 2 (deg) \t\t%.6f (avg)" % mean(angle(ff2.velocityField,deg=True))) print("Phase diff (deg) \t%.6f (avg)" % diff_P) print("") #===================================================================# #### Euler form of Fourier transformed field #### #===================================================================# print("==========================================") print("Reconstructed using Euler formula") print("==========================================") test_ff1 = abs(ff1.velocityField) * exp(1j * angle(ff1.velocityField)) test_ff2 = abs(ff2.velocityField) * exp(1j * angle(ff2.velocityField))
import Constants import logging import time # Instantiate objects. constant = Constants.ConstantsHandle() # Set logger configuration. logging.basicConfig(filename=constant.log_file_location + time.strftime("%Y-%m-%d", time.localtime()) + '.log', format="%(asctime)s:%(levelname)s:%(message)s", level=logging.DEBUG) # Instantiate logger. log = logging.getLogger(__name__) # Instantiate objects. test = Tests.TestHandle() # Log event. log.info('Starting DQSEGDB Regression Test Suite (' + constant.app_version + ')...') # Init. loop = True try: # Loop. while loop: # Begin attempt. try: test.run_test_suite() # If user stops server.
# Author: Gavrila Andrei # Scope: Fundamentals of Programming homework import Tests import App Tests.run() App.run() print("Come again!")
def test_deconstruct_field(original_ff_spectral, kx_array, kz_array, Nm, y, c, Re, baseflow, mean_profile, sparse): #===============================================================# #### Store the resolvent modes and amplitude coefficients #### # at each Fourier mode pair # #===============================================================# resolvent_modes_array = np.zeros((len(kx_array), len(kz_array), 3*Nm, 3*Nm), dtype=np.complex128) forcing_modes_array = np.zeros((len(kx_array), len(kz_array), 3*Nm, 3*Nm), dtype=np.complex128) coefficients_array = np.zeros((len(kx_array), len(kz_array), 3*Nm), dtype=np.complex128) sing_vals_array = np.zeros((len(kx_array), len(kz_array), 3*Nm), dtype=np.float64) #================================================================ #### Loop through wavenumbers #================================================================ chebyshev_differentiation, mean_flow_derivatives = ps.calculate_derivatives(Nm+2, mean_profile, baseflow) #================================================================ #### FFT mean profile #================================================================ spectral_deviation_profile = np.zeros((3*Nm),dtype=complex) if len(mean_profile) == 0: spectral_deviation_profile = original_ff_spectral[0,:,0] else: # Remove baseflow from turbulent mean profile baseflow_profile = [] if baseflow == "lam": # Laminary base flow baseflow_profile = 1.0 - y**2.0 elif baseflow == "cou": # Couette base flow baseflow_profile = y # Remove baseflow from mean to get turbulent deviation profile vel_profile = mean_profile - np.asarray(baseflow_profile) deviation_profile_sp = np.fft.fft(vel_profile) spectral_deviation_profile[1:Nm] = deviation_profile_sp[1:Nm] #================================================================ #### Loop through wavenumbers #================================================================ startTime = datetime.now() for mx in range(0, len(kx_array)): kx = kx_array[mx] print('\n\nkx:'+ str(kx)) for mz in range(0, len(kz_array)): kz = kz_array[mz] sys.stdout.write(".") sys.stdout.flush() if kx == 0 and kz == 0: # Zeroth Fourier modes resolvent_modes_array[mx, mz, :, 0] = spectral_deviation_profile continue # Start the loop again #-------------------------------------------------------- #### Calculate the state vectors #-------------------------------------------------------- omega = kx * c wegihted_transfer_function, w = ps.calculate_transfer_function(kx, kz, Re, Nm, omega, chebyshev_differentiation, mean_flow_derivatives) #-------------------------------------------------------- #### Perform SVD #-------------------------------------------------------- if sparse: weighted_resolvent_modes, singular_values, weighted_forcing_modes = svd(wegihted_transfer_function, full_matrices=False) else: weighted_resolvent_modes, singular_values, weighted_forcing_modes = svd(wegihted_transfer_function) #-------------------------------------------------------- #### Test: SVD #-------------------------------------------------------- Tests.SVD(weighted_resolvent_modes, singular_values, weighted_forcing_modes, wegihted_transfer_function, sparse) #-------------------------------------------------------- #### Test: Orthogonality #-------------------------------------------------------- Tests.orthogonality(weighted_resolvent_modes) Tests.orthogonality(weighted_forcing_modes) #-------------------------------------------------------- #### Test: Invertibility #-------------------------------------------------------- Tests.invertible(np.diag(singular_values)) #-------------------------------------------------------- #### Retrieve non-grid-weighted (physical) modes #-------------------------------------------------------- weighted_resolvent_modes = np.asmatrix(weighted_resolvent_modes) weighted_forcing_modes = np.asmatrix(weighted_forcing_modes) resolvent_modes = np.linalg.solve(w, weighted_resolvent_modes) forcing_modes = np.linalg.solve(w, weighted_forcing_modes) #-------------------------------------------------------- #### Check that the continuity condition is satisfied #-------------------------------------------------------- Tests.continuity(resolvent_modes, np.diag(singular_values), kx, kz, Nm, chebyshev_differentiation['D1']) #-------------------------------------------------------- #### Fix phase of resolvent modes based on critical layer or centreline #-------------------------------------------------------- phase_shift = np.zeros((resolvent_modes.shape[1], resolvent_modes.shape[1]), dtype=np.complex128) ind0 = Nm/2 + 1 # Use centreline, unless if c < 1.0: inds = Tests.indices(mean_flow_derivatives['U'].diagonal(), lambda x: x > c) if len(inds) > 0: ind0 = inds[0] np.fill_diagonal(phase_shift, np.exp(-1j * np.angle(resolvent_modes[ind0,:]))) resolvent_modes *= phase_shift #-------------------------------------------------------- #### Project resolvent modes to get amplitude coefficients #-------------------------------------------------------- # Initialize amplitude coefficients vector ampl_coeffs = np.zeros((3*Nm, 1), dtype=np.complex128) # Projection ampl_coeffs = inv(np.diag(singular_values)) * resolvent_modes.H * w.H * w * np.asmatrix(original_ff_spectral[mx, :, mz]).T Tests.projection(ampl_coeffs, np.diag(singular_values), resolvent_modes, np.asmatrix(original_ff_spectral[mx, :, mz]).T, 1e-10) # phase_test = False # norm_test = False # xi_norm = np.linalg.norm(xi) # if kz == 2.0 or kz == -2.0: # #xi_norm >= 1e-10: # # Phase test # if phase_test: # print("\nApplying phase shift at: " + str(kz) + "\n ") # # shift the field by pi/3 # xi += 1.0j*(np.pi/3.0) # # # Norm test # if norm_test: # print("\nApplying norm doubling.") # # Double the energy of the field # xi *= np.sqrt(2.0) + 1.0j*np.sqrt(2.0) # # # Fix xi to see if same coefficients are retrieved from projection # if fixXi: # xi[0] = 1.0 # xi[1] = 0.0 # print("\nXI:") # print("norm: " + str(xi_norm)) # print(xi) # print("") # print(xi) #-------------------------------------------------------- #### Store resolvent modes, singular values and amplitude coeffs. #-------------------------------------------------------- resolvent_modes_array[mx, mz, :, :] = resolvent_modes forcing_modes_array[mx, mz, :, :] = forcing_modes coefficients_array[mx, mz, :] = np.squeeze(np.asarray(ampl_coeffs)) sing_vals_array[mx, mz, :] = singular_values calcTime = datetime.now() - startTime print("\n\n\n") print(calcTime) print("\n\n\n") deconstructed_dict = {} deconstructed_dict['resolvent_modes'] = resolvent_modes_array deconstructed_dict['forcing_modes'] = forcing_modes_array deconstructed_dict['singular_values'] = sing_vals_array deconstructed_dict['coefficients'] = coefficients_array return deconstructed_dict
def tests_for_single_bpm(test_sys, data_location, rf_frequency, settling_time=0.1): root_path = '/'.join( (data_location, test_sys.BPM.mac_address.replace(':', '-'), time.strftime("%d-%m-%Y_T_%H-%M"))) if not os.path.exists(root_path): os.makedirs(root_path) subdirectory = ''.join((root_path, '/')) data_out = { 'epics_id': test_sys.BPM.epics_id, 'rf_id': test_sys.rf_id, 'prog_atten_id': test_sys.prog_atten_id, 'mac_address': test_sys.BPM.mac_address, 'first_turn': test_sys.BPM.ft, 'agc': test_sys.BPM.agc, 'delta': test_sys.BPM.delta, 'switches': test_sys.BPM.switches, 'switch_val': test_sys.BPM.switch_val, 'attenuation': test_sys.BPM.attn, 'dsc': test_sys.BPM.dsc, 'kx': test_sys.BPM.kx, 'ky': test_sys.BPM.ky, 'bpm_spec': test_sys.BPM.spec } with open(subdirectory + "initial_BPM_state.json", 'w') as write_file: json.dump(data_out, write_file) Tests.adc_test(test_system_object=test_sys, frequency=rf_frequency, output_power_level=-4, settling_time=settling_time, sub_directory=subdirectory) Tests.adc_int_atten_sweep_test(test_system_object=test_sys, frequency=rf_frequency, output_power_level=-4, settling_time=settling_time, sub_directory=subdirectory) Tests.beam_power_dependence(test_system_object=test_sys, frequency=rf_frequency, output_power_levels=range(-4, -30, -5), settling_time=settling_time, samples=100, sub_directory=subdirectory) Tests.beam_position_equidistant_grid_raster_scan_test( test_system_object=test_sys, rf_frequency=rf_frequency, output_power_level=-6, x_points=3, y_points=3, settling_time=settling_time, samples=100, sub_directory=subdirectory) print '\nData stored in ', subdirectory return subdirectory
import Tests if __name__ == '__main__': print "WoWLootSimulator::Begin" numberOfFreshGearingRuns = 10000 numberOfRaidWeeks = 40 lootSimulationTest = Tests.Tests(numberOfFreshGearingRuns, numberOfRaidWeeks) #lootSimulationTest.Test_Realistic() lootSimulationTest.Test_Realistic_BalancedRoster() #lootSimulationTest.Test_PerfectLootCouncil_BalancedRoster() #lootSimulationTest.Test_NoPersonalLootItemTrading() print "WoWLootSimulator::End"
import pyglet from pyglet.gl import gl import Tests import os import qatrack import copy # copies files from qa folder and puts it in our directory os.system("del_copy.bat") # get all our test names and get unique parent tests (i.e ML11 from ML11_e and ML11_p) tests = Tests.tests() unique_tests = list(set([t.split('_')[0] for t in tests.test_info.keys()])) unique_tests.sort() organized_tests = {} for t in tests.test_info: parent_test = t.split('_')[0] if parent_test not in organized_tests: organized_tests[parent_test] = [t] else: organized_tests[parent_test].append(t) print organized_tests background_color = (0.98, 0.98, 0.98, 1) class Rectangle(object): '''Draws a rectangle into a batch.'''
" State: " + str(self.state) + "\n" + " Country: " + str(self.country) + "\n") def delLastName(self): # TODO this is broken because dict key self.lastname = '' # testing if __name__ == '__main__': # Book class bookobj = Book('jfb_000') # add first contact Tests.testbook(bookobj=bookobj, firstname='Jesse', lastname='Bowman', phonenumber='423.555.3443', emailaddress='*****@*****.**', street='1506 12th Ave Unit 420', city='Seattle', state='WA', country='USA') # add second contact Tests.testbook(bookobj=bookobj, firstname='Clandor', lastname='Dinkles', phonenumber='555.341.3443', emailaddress='*****@*****.**', street='1414', city='Bristol', state='TN', country='USA') # add third contact with shared values Tests.testbook(bookobj=bookobj, firstname='Jesse\'s', lastname='GF', phonenumber='205.555.1123', emailaddress='*****@*****.**', street='', city='Seattle', state='WA', country='USA') # add a fourth contact with different shared values (want to test searching by some matches and some not) Tests.testbook(bookobj=bookobj, firstname='Jesse', lastname='Other', phonenumber='423.555.3443', emailaddress='*****@*****.**', street='1506 12th Ave Unit 421', city='Seattle', state='WA', country='USA')
import generadores as gn import Tests as ts import numpy.matlib as np import random gen = gn.ranGen() testers = ts.tests() nrosRandomLFG = gen.randLFG(6,7,100) nrosRandomGLC = gen.randGCL(15,100) nrosRandomPy = [] for i in range(100): nrosRandomPy.append(random.random()) #testers.testCorridas(nrosRandom) print('------------------------------------------------------------------------------') print('| Generadores \ Test | Chi Cuadrado | Kolmogorov-Smirnov | Corridas | Series |') print('|--------------------|--------------|--------------------|----------|--------|') print('| GLC | '+testers.chiSqTest(nrosRandomGLC)+' | '+testers.testKS(nrosRandomGLC)+' | '+testers.testCorridas(nrosRandomGLC)+' | '+testers.series(nrosRandomGLC)+'|') print('|--------------------|--------------|--------------------|----------|--------|') print('| LFG | '+testers.chiSqTest(nrosRandomLFG)+' | '+testers.testKS(nrosRandomLFG)+' | '+testers.testCorridas(nrosRandomLFG)+' | '+testers.series(nrosRandomLFG)+'|') print('|--------------------|--------------|--------------------|----------|--------|') print('| randrange | '+testers.chiSqTest(nrosRandomPy)+' | '+testers.testKS(nrosRandomPy)+' | '+testers.testCorridas(nrosRandomPy)+' | '+testers.series(nrosRandomPy)+'|') print('------------------------------------------------------------------------------') #for i in nrosRandom: # print(i)
def debug(self): r = jsonpickle.encode(Tests.test_puntuacion(), unpicklable=False) return json.loads(r)
def main(File, Details, MeanProfile, Sparse): #================================================================ #### Format the output directory #================================================================ if File[-3:] == ".h5": # print("HDF5 file given.") #------------------------------------------------------------ #### Read the HDF5 and details file #------------------------------------------------------------ file_info, original_attrs = ut.read_H5(File) details = ut.read_Details(Details) elif File[-3:] == ".ff": # print("Channelflow binary file given.") #------------------------------------------------------------ #### Convert from .ff to .h5 #------------------------------------------------------------ command = "fieldconvert " + File + " " + File[:-3] + ".h5" #------------------------------------------------------------ #### Read the HDF5 and details file #------------------------------------------------------------ file_info = ut.read_H5(File) details = ut.read_Details(Details) else: # No file type given. ut.error("Invalid file given.") field_u = file_info['ff'][0,:,:,:] field_v = file_info['ff'][1,:,:,:] field_w = file_info['ff'][2,:,:,:] #================================================================ #### Initialise flow field object for field (to approximate) #================================================================ ff_original = ffClass.FlowFieldChannelFlow( file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'], file_info['Lx'], file_info['Lz'], file_info['alpha'], file_info['beta'], details['c'], details['bf'], details['Re'], file_info['ff'], "pp") Tests.fft_ifft(ff_original) #================================================================ #### Check velocity profile #================================================================ # Create empty 4D array to store mean flow field mean = np.zeros((file_info['Nd'], file_info['Nx'], file_info['Ny'], file_info['Nz'])) mean_profile = [] if MeanProfile: # Velocity profile given #------------------------------------------------------------ #### Read velocity profile #------------------------------------------------------------ vel_profile = ut.read_Vel_Profile(MeanProfile) # Check to see if it is a mean profile or a deviation profile. deviation = any(n < 0 for n in vel_profile) if deviation: # Deviation profile given # Add baseflow to deviation baseflow = [] if details['bf'] == "lam": # Laminary base flow baseflow = 1.0 - ff_original.y**2.0 elif details['bf'] == "cou": # Couette base flow baseflow = ff_original.y # Add baseflow to deviation to get turbulent mean profile mean_profile = vel_profile + np.asarray(baseflow) else: # Turbulent mean profile given mean_profile = vel_profile #================================================================ #### ---- Remove the wall boundaries #================================================================ # Removing the xz-planes at y=1 and y=-1, # so that the chebyshev nodes can be used to construct # the transfer function. ff_original.remove_wall_boundaries() #================================================================ #### ---- Fourier transform in xz directions #================================================================ ff_original.make_xz_spectral() #================================================================ #### ---- Stack velocity fields in the wall-normal direction #================================================================ ff_original.stack_ff_in_y() #================================================================ #### Create arrays of Fourier modes to use #================================================================ # Modes multiplied with fundamental wavenumbers #(Modes: the physical modes, i.e. the grid points) kx_array = ff_original.Mx * ff_original.alpha kz_array = ff_original.Mz * ff_original.beta #================================================================ #### Deconstruct original flow field #================================================================ deconstructed_field = cr.deconstruct_field(ff_original.velocityField, kx_array, kz_array, ff_original.numModes, ff_original.y, ff_original.c, ff_original.Re, ff_original.baseflow, mean_profile, Sparse) #================================================================ #### Write decomposed flow field to disk as an HDF5 file #================================================================ ut.write_H5_Deconstructed(deconstructed_field, original_attrs, ff_original, File[:-3])
time.sleep(2) TCP_IP = '10.42.0.10' TCP_PORT = 5000 BUFFER_SIZE = 1024 s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((TCP_IP,TCP_PORT)) s.close() s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((TCP_IP,TCP_PORT)) passed = Tests.test0(s) print ('0: ' + str(passed)) if (passed == False): exit() print ('1: ' + str(Tests.test1(s))) print ('2: ' + str(Tests.test2(s))) print ('3: ' + str(Tests.test3(s))) print ('4: ' + str(Tests.test4(s))) print ('5: ' + str(Tests.test5(s))) print ('6: ' + str(Tests.test6(s)))
def main(repo, repourl, build, branch, buildtype, url=None, profile="minimal", readonlymode=""): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): for option in config.options(buildtype): line = config.get(buildtype, option) line = line.split(',') for entry in line: if option.strip() in repo: env.host = entry.strip() print "===> Host is %s" % env.host break # Didn't find any host in the map for this project. if env.host is None: raise ValueError( "===> You wanted to deploy a build but we couldn't find a host in the map file for repo %s so we're aborting." % repo) user = "******" # Set our host_string based on user@host env.host_string = '%s@%s' % (user, env.host) # Set SSH key if needed ssh_key = None if "*****@*****.**" in repourl: ssh_key = "/var/lib/jenkins/.ssh/id_rsa_github" # Set a URL if one wasn't already provided if url is None: url = "%s.%s.%s" % (repo, branch, env.host) # Run the tasks. # -------------- # If this is the first build, attempt to install the site for the first time. with settings(warn_only=True): if run('drush sa | grep \'^@\?%s_%s$\' > /dev/null' % (repo, branch)).failed: fresh_install = True else: fresh_install = False if fresh_install == True: print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) InitialBuild.initial_build(repo, url, branch, build, profile) AdjustConfiguration.adjust_drushrc_php(repo, branch, build) common.Services.clear_php_cache() common.Services.clear_varnish_cache() common.Services.reload_webserver() InitialBuild.generate_drush_alias(repo, url, branch) Drupal.generate_drush_cron(repo, branch) except: e = sys.exc_info()[1] raise SystemError(e) else: print "===> Looks like the site %s exists already. We'll try and launch a new build..." % url # Grab some information about the current build previous_build = common.Utils.get_previous_build( repo, cleanbranch, build) previous_db = common.Utils.get_previous_db(repo, cleanbranch, build) Drupal.backup_db(repo, branch, build) common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) Updates.merge_prod(repo, branch, build) AdjustConfiguration.adjust_settings_php(repo, branch, build, previous_build, buildtype) AdjustConfiguration.adjust_drushrc_php(repo, branch, build) AdjustConfiguration.adjust_files_symlink(repo, branch, build) Drupal.drush_status(repo, branch, build) Drupal.go_offline(repo, branch, build, readonlymode) # No need for this, drush_up does it later # drush_updatedb(repo, branch, build) # This will revert the database if it fails common.Utils.adjust_live_symlink( repo, branch, build) # This will revert the database if it fails Updates.drush_up(repo, branch) Drupal.drush_status( repo, branch, build, revert=True ) # This will revert the database if it fails (maybe hook_updates broke ability to bootstrap) Updates.add_push_updates(repo, branch, build) Drupal.go_online( repo, branch, build, previous_build, readonlymode ) # This will revert the database and switch the symlink back if it fails common.Services.clear_php_cache() common.Services.clear_varnish_cache() Drupal.generate_drush_cron(repo, branch) Tests.run_tests(repo, branch, build) #run_behat_tests(repo, branch, build) #commit_new_db(repo, repourl, url, build, branch) common.Utils.remove_old_builds(repo, branch) Updates.send_update_notification(repo, branch) script_dir = os.path.dirname(os.path.realpath(__file__)) if put(script_dir + '/../util/revert', '/home/jenkins', mode=0755).failed: print "####### BUILD COMPLETE. Could not copy the revert script to the application server, revert will need to be handled manually" else: print "####### BUILD COMPLETE. If you need to revert this build, run the following command: sudo /home/jenkins/revert -b %s -d %s -s /var/www/live.%s.%s -a %s_%s" % ( previous_build, previous_db, repo, branch, repo, branch)