Example #1
0
 def test_load_save(self):
     automata = Automata(fname='test_data/automata-example.json')
     config = B2gConfiguration('test-app-name', 'test-app-id', mkdir=False)
     config.set_path('root', 'test_data')
     config.set_path('dom', 'test_data/dom')
     config.set_path('state', 'test_data/screenshot/state')
     config.set_path('clickable', 'test_data/screenshot/clickable')
     saved_file_path = automata.save(config)
     import filecmp
     self.assertTrue(filecmp.cmp('test_data/automata-example.json', 'test_data/automata.json'))
     try:
         os.remove(saved_file_path)
     except OSError:
         pass
Example #2
0
# Create automata with default options
opts = AutomataOptions(steps, universe_grid_size, neighborhood_grid_size,
                       thresholds, alive_t, DEAD_T)

a = Automata(opts)

if args.log_params:
    print("\nparams:\n{}".format(a.options.to_dict()))

if len(args.load_from):
    load_path = args.load_from
    files = glob.glob(load_path)
    files.sort()
    a.load(files)
    # Load from filesystem
else:
    # Run for n-steps
    a.run()

if args.stats:
    print("\nstats:\n{}".format(a.to_dict()))

if args.plot:
    # Plot result
    p = Plotter(a)
    p.plot(should_animate)

if len(args.save_to):
    a.save(args.save_to)