def test_invalid_algorithm(_): with mock.patch('sys.argv', [ './simulator.py', '--lb', 'non-existant', ]): main()
def run(exp_id='', run_id=0, runpath=''): _, runs = eval(f'config{exp_id}()') config = runs[run_id] if runpath != '': os.chdir(runpath) pickle._dump(config, open('config.pickle', 'wb')) main(config)
def test_autoscaler(_): with mock.patch('sys.argv', [ './simulator.py', '--lb', 'SQF', '--rc', 'mm_queueifac', '--scenario', './scenarios/autoscaling-support.py', ]): main()
def startElcanoSim(self): try: COMPort = self.deviceDict[self.portSelected.get()] simulator.main(COMPort, self.IPEntry.get(), int(self.portEntry.get())) except: print('No port connected! Using custom controller') simulator.main('COM7', self.IPEntry.get(), int(self.portEntry.get()), 'custom_controller')
def test_all(): outdir = tempfile.mkdtemp() print('Using:', outdir, file = sys.stderr) with mock.patch('sys.argv', [ './simulator.py', '--ac', 'ALL', '--rc', 'ALL', '--scenario', './scenarios/autoscaling-support.py', '--outdir', outdir ]): main() shutil.rmtree(outdir)
def run_simulator(dirname, nodes, etypes, events, execs): ''' Run the parametrized simulator and store the log of simulator events in a parametrized filename. ''' fname = dirname + "/nodes-%d_etypes-%d_events-%d_execs-%d.txt" % (nodes, etypes, events, execs) f = open(fname, 'w') def logEventFn(e): f.write(e + "\n") # os.system("python simulator.py %d %d %d %d > %s" % (nodes, etypes, events, execs, fname)) simulator.main(nodes, etypes, events, execs, logEventFn) f.close()
def run_simulator(dirname, nodes, etypes, events, execs): ''' Run the parametrized simulator and store the log of simulator events in a parametrized filename. ''' fname = dirname + "/nodes-%d_etypes-%d_events-%d_execs-%d.txt" % ( nodes, etypes, events, execs) f = open(fname, 'w') def logEventFn(e): f.write(e + "\n") # os.system("python simulator.py %d %d %d %d > %s" % (nodes, etypes, events, execs, fname)) simulator.main(nodes, etypes, events, execs, logEventFn) f.close()
def check_residue(lbAlgorithm, output): """ Ensure the algorithm behaves exactly the same as it used to, in preparation for some intrusive refactoring. """ with mock.patch('sys.argv', [ './simulator.py', '--rc', 'mm_queueifac', '--lb', lbAlgorithm, '--scenario', 'scenarios/static_basic.py', ]): main() output.assert_called_with(*RESIDUE_TABLE[lbAlgorithm])
def main(): prompt = Prompt() carrega = 'tracefile' espaco = 1 substitui = 2 intervalo = None ram = '/tmp/ep2.mem' swap = '/tmp/ep2.vir' pagina = 16 while True: command = prompt.read() if command.is_valid(): if command.argv[0] == 'sai': break if command.argv[0] == 'carrega': carrega = command.argv[1] else: try: comm = command.argv[0] param = int(command.argv[1]) if comm == 'espaco': espaco = param elif comm == 'substitui': substitui = param elif comm == 'executa': intervalo = param except: print ("%s\n%s" % (command.get_error(), prompt.help())) continue """ Executa o simulador """ if command.argv[0] == 'executa' and isinstance(intervalo, int) and intervalo > 0: simulator.main(ram, swap, pagina, carrega, substitui, espaco, intervalo) else: print ("%s\n%s" % (command.get_error(), prompt.help()))
def run(self): simulator.main(timestamp, csv_name, quiet, True) #pokretanje simulatora
def main(path=None,regen=False): updated = 'Sep 4 2019' #ASCII graphics generation logo = open('config/logo.txt','r') print logo.read() logo.close() print "-"*90 print "CHROMA RAYTRACER FOR VUV SETUP".center(90,'=') print "-"*90+'\n' print "For help, please consult the user manual\nor contact Ben Page at [email protected]\n" print "Last Updated " + updated print "="*90 if path!=None: print 'Loading in predefined parameters...' params = open(path,'r') expression = params.readline() print expression n,wavelength,width,beamsize = [float(i) for i in expression.split(':')] else: print 'PLEASE SPECIFY THE SETUP PARAMETERS' print '[You can exit at any time by typing "exit"]\n' flag = False while flag == False: statements = [ 'Input number of photons: ', 'Input wavelength (nm): ', u'Input slit width (\u03bcm): '.encode('utf-8'), u'Input width of light source (\u03bcm): '.encode('utf-8')] values = [] for pos, statement in enumerate(statements): while True: usrin = raw_input(statement).strip() if usrin in ['Exit','exit']: exit() else: try: values.append(float(usrin)) break except: print 'Bad input! Please enter a type int/float!' n,wavelength,width,beamsize = values if width > 1000: print u'Width cannot be greater than 1000\u03bcm'.encode('utf-8') else: print '\nSelected Inputs:\n'+'='*20 print 'Number of photons = ',n print 'Wavelength = ',wavelength print 'Slit width = ',width print 'Beam Size = ',beamsize,'\n' while True: usrin = raw_input('Proceed? [Y/N] : ').strip() if usrin in ['yes','Yes','Y','y']: flag = True break elif usrin in ['no','No','N','n']: break else: print 'Bad Input: Please confirm your selection.' #Cleaning inputs n = int(n) wavelength = int(wavelength) width /= 25400.0 #Metric to Imperial conversion beamsize /= 25400.0 simulator.main(n,wavelength,width,beamsize,regen)
xtol=1e-30, ftol=1e-30, gtol=1e-30, # loss = 'soft_l1', # loss = 'cauchy', args=(state_size, counter_antennas, antennas, counter_pulses, measurements, dt, c), x0=p0, verbose=2) # print solution p = solution.x return p.reshape(counter_pulses, state_size) if '__main__' == __name__: date = simulator.main() print date config = read_data('configuration', date) # type: Configuration _real_coordinates = read_data('real_coordinates', date) _pulsing_coordinates = read_data('pulsing_coordinates', date) measured_times = read_data('measured_times', date) hover = HoverTool(tooltips=[ ("index", "$index"), ("(x,y)", "(@x, @y)"), ]) figure = plotting.figure(tools=[ "pan,box_zoom,zoom_out,reset,save,crosshair", hover, ], title="Reverse GPS simulation- {}".format(date),
def sim(queue): print("Starting Simulator...") simulator.main(queue)
def test_main(_): with mock.patch('sys.argv', [ './simulator.py', '--lb', 'SQF', ]): main()
def startElcanoSim(self): COMPort = self.deviceDict[self.portSelected.get()] simulator.main(COMPort, self.IPEntry.get(), int(self.portEntry.get()))
from simulator import main if __name__ == '__main__': main()