本文整理汇总了Python中visualizer.Visualizer类的典型用法代码示例。如果您正苦于以下问题:Python Visualizer类的具体用法?Python Visualizer怎么用?Python Visualizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Visualizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, args):
Visualizer.__init__(self, args)
self.inner_margin_width = int(self.width * INNER_MARGIN)
self.safe_width = self.width - self.inner_margin_width * 2
self.files = {}
self._smoothed_min_filenum = Smoother()
self._smoothed_max_filenum = Smoother()
示例2: debugTestMain
def debugTestMain(folderpath, dirname):
logging.info(" setting config...")
config = SeleniumConfiguration(Browser.FireFox, "http://140.112.42.145:2000/demo/nothing/main.html")
config.set_max_depth(1)
config.set_max_length(5)
config.set_trace_amount(1)
config.set_max_states(100)
config.set_folderpath(folderpath)
config.set_dirname(dirname)
config.set_automata_fname('automata.json')
config.set_traces_fname('traces.json')
config.set_frame_tags(['iframe'])
config.set_dom_inside_iframe(True)
config.set_simple_clickable_tags()
config.set_simple_inputs_tags()
config.set_simple_normalizers()
logging.info(" setting executor...")
executor = SeleniumExecutor(config.get_browserID(), config.get_url())
logging.info(" setting crawler...")
automata = Automata(config)
databank = InlineDataBank("140.112.42.145:2000", "jeff", "zj4bj3jo37788", "test")
algorithm = MonkeyCrawler() #DFScrawler()
crawler = SeleniumCrawler(config, executor, automata, databank, algorithm)
logging.info(" crawler start run...")
crawler.run_algorithm()
logging.info(" end! save automata...")
algorithm.save_traces()
automata.save_automata(config.get_automata_fname())
Visualizer.generate_html('web', os.path.join(config.get_path('root'), config.get_automata_fname()))
config.save_config('config.json')
示例3: __init__
def __init__(self, args):
Visualizer.__init__(self, args)
self.safe_width = int(self.width * (1 - APPEND_MARGIN - PREPEND_MARGIN))
self.prepend_margin_width = int(self.width * PREPEND_MARGIN)
self.files = {}
self._smoothed_min_filenum = Smoother()
self._smoothed_max_filenum = Smoother()
示例4: main
def main(m=5, r=2, window_size=20, batch_size=2):
gen = SimpleGenerator(num=m)
bed = TestBed(m=m, r=r, window_size=window_size, batch_size=batch_size)
vis = Visualizer()
for i in xrange(10):
bed.supply(gen.next())
for i,y in enumerate(gen):
if i % window_size == 0:
# pretrain
avg_cost = bed.pretrain(10, pretraining_lr=0.1)
print(" pretrain cost: {}".format(avg_cost))
# predict
y_pred = bed.predict()
print("{}: y={}, y_pred={}".format(i, y, y_pred))
vis.append(y, y_pred)
# finetune
bed.supply(y)
avg_cost = bed.finetune(10, finetunning_lr=0.1)
# bed.finetune(100, finetunning_lr=0.01)
# bed.finetune(100, finetunning_lr=0.001)
print(" train cost: {}".format(avg_cost))
time.sleep(.1)
示例5: SeleniumMain
def SeleniumMain(web_submit_id, folderpath=None, dirname=None):
logging.info(" connect to mysql")
print("connect to sql")
databank = MysqlDataBank("localhost", "root", "", "test")
url, deep, time = databank.get_websubmit(web_submit_id)
logging.info(" setting config...")
print(" setting config...")
config = SeleniumConfiguration(Browser.PhantomJS, url, folderpath, dirname)
config.set_max_depth(deep)
config.set_max_time(int(time)*60)
config.set_simple_clickable_tags()
config.set_simple_inputs_tags()
config.set_simple_normalizers()
config.set_frame_tags(['iframe'])
logging.info(" setting executor...")
executor = SeleniumExecutor(config.get_browserID(), config.get_url())
logging.info(" setting crawler...")
automata = Automata()
crawler = SeleniumCrawler(config, executor, automata, databank)
logging.info(" crawler start run...")
automata = crawler.run()
crawler.close()
logging.info(" end! save automata...")
automata.save_automata(config)
automata.save_traces(config)
Visualizer.generate_html('web', os.path.join(config.get_path('root'), config.get_automata_fname()))
config.save_config('config.json')
示例6: run_algorithm
def run_algorithm(self):
# repeat for trace_amount times
for i in range( self.configuration.get_trace_amount() ):
self.initial()
while self.action_events:
#check time
if (time.time() - self.time_start) > self.configuration.get_max_time():
logging.info("|||| TIMO OUT |||| end crawl ")
break
string = ''.join([ str(action['action']['clickable'].get_id())+str(action['depth'])+str(action['state'].get_id()) for action in self.action_events ])
logging.info(' action_events : '+string )
state, action, depth = self.get_next_action()
self.change_state(state, action, depth)
edge = self.trigger_action(state, action, depth)
self.update_states(state, edge, action, depth)
self.close()
self.algorithm.save_traces()
self.automata.save_automata(self.configuration.get_automata_fname())
Visualizer.generate_html('web', os.path.join(self.configuration.get_path('root'), self.configuration.get_automata_fname()))
return self.automata
示例7: test_generate_report
def test_generate_report(self):
num_clickables = {
'unexamined': 5,
'true': 10,
'false': 30
}
form1 = FormField('form1')
form1.add_input(InputField('username', '//*[@id="username"]', 'castman'))
form1.add_input(InputField('password', '', '[email protected]'))
form_list = [{
'state': 1,
'form': form1,
'execution_seq': [Clickable('exe1', '//html/body/button[1]'), Clickable('exe2', '//html/body/button[1]')],
'clickable': [Clickable('btn1', '//html/body/button[1]'), Clickable('btn2', '//html/body/button[1]')]
}]
inv_violation = [{
'state': 2,
'name': '{"name": "file-not-found"}',
'sequence': [Clickable('inv-btn1', '//html/body/button[1]'), Clickable('inv-btn2', '//html/body/button[1]')]
}]
Visualizer.generate_report(
'web',
'trace/example-app-4-webide',
'automata.json',
3, num_clickables, form_list, inv_violation, 9.987
)
示例8: CBTestMain
def CBTestMain(folderpath, dirname,web_submit_id):
logging.info(" Type: Cross Browser Testing")
logging.info(" connect to mysql")
print("")
print("connect to sql")
databank = MysqlDataBank("localhost", "root", "", "test")
url, deep, time, b1, b2 = databank.get_websubmit(int(web_submit_id))
basic_browserID = str(b1)
other_browserID = str(b2)
depth = int(deep)
logging.info(" A new CBT begings...")
logging.info(" setting config...")
config = SeleniumConfiguration(int(basic_browserID),int(other_browserID), url)
# max 3
config.set_max_depth(int(depth))
# max 3
config.set_max_length(int(depth))
# should be 1
config.set_trace_amount(1)
# should be 100 no use?
config.set_max_states(5)
config.set_folderpath(folderpath)
config.set_dirname(dirname)
config.set_automata_fname('automata.json')
config.set_traces_fname('traces.json')
#config.set_frame_tags(['iframe'])
config.set_dom_inside_iframe(True)
config.set_simple_clickable_tags()
config.set_simple_inputs_tags()
config.set_simple_normalizers()
logging.info(" setting executor...")
#nothing here
executor = CBTExecutor(config.get_browserID(), config.get_url())
logging.info(" setting crawler...")
automata = Automata(config)
#databank = InlineDataBank("140.112.42.145:2000", "jeff", "zj4bj3jo37788", "test")
databank = InlineDataBank("localhost", "B00901138", "R124249166", "test")
print('start Cross Browser Testing...')
#acually it's CBT algorithm
algorithm = CBTCrawler(int(other_browserID),url)
crawler = SeleniumCrawler(config, executor, automata, databank, algorithm)
logging.info(" crawler start runing...")
crawler.run_algorithm()
print(" end! save automata...")
logging.info(" end! save automata...")
algorithm.save_traces()
automata.save_automata(config.get_automata_fname())
Visualizer.generate_html('web', os.path.join(config.get_path('root'), config.get_automata_fname()))
config.save_config('config.json')
示例9: PhysPopulation
class PhysPopulation(AnnPopulation):
"""Population class for the physical EvoFab system. Is used to
wrap up a significant amount of information important for the
execution of the GA within members
"""
def __init__(self, random_seed, printer_runtime, size, mutation_rate, mutation_range, crossover_rate, replacement_number, num_input, num_hidden, num_output, serial_port, sensor_serial_port, conveyor_port, z_port, camera, outputfolder, crop=True, is_visual=True, dump_to_files=False):
super(PhysPopulation, self).__init__(random_seed, printer_runtime, size, mutation_rate, mutation_range, crossover_rate, replacement_number, num_input, num_hidden, num_output, outputfolder, is_visual=is_visual, dump_to_files=dump_to_files)
self.genotype_factory = PhysGenotypeFactory(self)
#TODO: should probably test that sensor and controller serial ports are valid
self.controller = EvoController(serial_port)
self.sense = EvoArray(sensor_serial_port)
self.camera = EvoCamera(camera, crop)
self.conveyor = EvoConveyor(conveyor_port)
self.visualizer = Visualizer([self.sense.getNext() for x in range(10)])
self.visualizer.update(self.sense.getNext())
self.z_axis = EvoZAxis(z_port)
listener = threading.Thread(target=kbdListener)
listener.start()
示例10: setup
def setup(self, window_size=20, t_in=2, w=10, h=10, d=1, t_out=1, hidden_layers_sizes=[100], pretrain_step=1):
self.bed = TestBed(window_size=window_size, t_in=t_in, w=w, h=h, d=d, t_out=t_out, hidden_layers_sizes=hidden_layers_sizes)
self.gen = SinGenerator(w=w, h=h, d=1)
# self.gen = RadarGenerator('../data/radar', w=w, h=h, left=0, top=80)
self.vis = Visualizer(w=w, h=h, t_out=t_out)
self.pretrain_step = pretrain_step
# fill the window with data
for i in xrange(window_size):
y = self.gen.next()
self.bed.supply(y)
示例11: main
def main():
# get settings from command line arguments
settings = CommandLineParser().parse_args()
# create problem
problem = GrayScottProblem(settings.size, coefficients=settings.coefficients)
# create visualizer
visualizer = Visualizer(problem.problem_size(), \
export=settings.export, \
keepalive=settings.keepalive, \
show=(not settings.noshow))
# create step generator
stop_point_generator = TimeStepper(settings.timesteps, \
settings.outputs, mode='linear')
# evolution loop
stop_point = next(stop_point_generator)
for step in range(settings.timesteps + 1):
# print progress message
if settings.verbose == True:
progress = 100 * step / settings.timesteps
print('{:3.0f}% finished'.format(progress), end='\r')
# trigger visualization
if step == stop_point:
visualizer.update(problem.v)
try:
stop_point = next(stop_point_generator)
except StopIteration:
pass
# evolve problem
problem.evolve()
else:
if settings.verbose == True:
print('\nEvolution finished')
visualizer.close()
示例12: __init__
def __init__(self, random_seed, printer_runtime, size, mutation_rate, mutation_range, crossover_rate, replacement_number, num_input, num_hidden, num_output, serial_port, sensor_serial_port, conveyor_port, z_port, camera, outputfolder, crop=True, is_visual=True, dump_to_files=False):
super(PhysPopulation, self).__init__(random_seed, printer_runtime, size, mutation_rate, mutation_range, crossover_rate, replacement_number, num_input, num_hidden, num_output, outputfolder, is_visual=is_visual, dump_to_files=dump_to_files)
self.genotype_factory = PhysGenotypeFactory(self)
#TODO: should probably test that sensor and controller serial ports are valid
self.controller = EvoController(serial_port)
self.sense = EvoArray(sensor_serial_port)
self.camera = EvoCamera(camera, crop)
self.conveyor = EvoConveyor(conveyor_port)
self.visualizer = Visualizer([self.sense.getNext() for x in range(10)])
self.visualizer.update(self.sense.getNext())
self.z_axis = EvoZAxis(z_port)
listener = threading.Thread(target=kbdListener)
listener.start()
示例13: main
def main():
cerebellum.registerMessageHandler(TestHandler())
staticMap = StaticMap()
cerebellum.registerMessageHandler(staticMap)
logic = SimpleStackLogic(cerebellum,staticMap)
cerebellum.registerMessageHandler(logic)
if visualize:
from visualizer import Visualizer
import simple_stack_visualizer
vis = Visualizer(cerebellum, staticMap)
vis.registerDrawer(simple_stack_visualizer.createDrawer(logic))
vis.start()
vis.registerDrawer(cerebellum.insurance.draw)
mainLoop()
if visualize:
vis.terminate = True
vis.join()
示例14: SeleniumMutationTrace
def SeleniumMutationTrace(folderpath, dirname, config_fname, traces_fname, trace_id, method_id, modes):
logging.info(" loading config...")
config = load_config(config_fname)
config.set_folderpath(folderpath)
config.set_dirname(dirname)
config.set_mutation_trace(traces_fname, trace_id)
config.set_mutation_method(method_id)
config.set_mutation_modes(modes)
logging.info(" setting executor...")
executor = SeleniumExecutor(config.get_browserID(), config.get_url())
logging.info(" setting crawler...")
automata = Automata()
databank = MysqlDataBank("localhost", "B00901138", "R124249166", "test")
crawler = SeleniumCrawler(config, executor, automata, databank)
logging.info(" crawler start run...")
crawler.run_mutant()
logging.info(" end! save automata...")
automata.save_traces(config)
automata.save_automata(config)
Visualizer.generate_html('web', os.path.join(config.get_path('root'), config.get_automata_fname()))
示例15: __init__
def __init__(self, vis=False):
"""
Creates a new Driver.
Args:
vis: Boolean. Whether or not to show visualization of the simulation
runs using matplotlib.
Returns:
A new Driver instance.
"""
self.vis = vis
# If visualization is selected, show it.
if self.vis:
series = ('Population Count',
'Adult Count',
'Caloric Requirements (Mcal)',
'Produced Food (Mcal)',
'Air (kg O2)',
'Power Consumption (kWh)')
self.vis = Visualizer(series=series)