def generate_configs(l, h, j, initial_lattice, n_configs, n_usable_configs, t_tilde): lattice_full = zeros((l, l, n_configs)) for x in range(n_configs): for t in range(l**2): r = int(random.random() * l) c = int(random.random() * l) new_lattice = initial_lattice new_lattice[r, c] = new_lattice[r,c] * -1 #print new_lattice.shape padded_new_lattice = pad(new_lattice) [accepted, accepted_prob] = test_grid(h, j, padded_new_lattice, r, c, t_tilde) if accepted: lattice = new_lattice lattice_full[:,:,x] = lattice size_z = lattice_full.shape[2] lattice3D = lattice_full[:,:,size_z-n_usable_configs:size_z] return lattice3D
def create_lattice(l, h, j, initial_lattice, n_configs, n_usable_configs, t_tilde): lattice_full = numpy.zeros((l, l, n_configs)) lattice = initial_lattice for x in range(0, n_configs): for t in range(0, l ** 2): r = floor(random.random() * l) c = floor(random.random() * l) new_lattice = lattice new_lattice[r, c] *= -1 padded_new_lattice = pad(new_lattice) [accepted, accepted_prob] = test_grid(h, j, padded_new_lattice, r, c, t_tilde) if accepted: lattice = new_lattice lattice_full[:, :, x] = lattice lattice_full = numpy.delete(lattice_full, range(0, n_configs - n_usable_configs), 2) return lattice_full
def generate_configs(l, h, j, initial_lattice, n_configs, n_usable_configs, t_tilde): lattice_full = zeros((l, l, n_configs)) for x in range(n_configs): for t in range(l**2): r = int(random.random() * l) c = int(random.random() * l) new_lattice = initial_lattice new_lattice[r, c] = new_lattice[r, c] * -1 #print new_lattice.shape padded_new_lattice = pad(new_lattice) [accepted, accepted_prob] = test_grid(h, j, padded_new_lattice, r, c, t_tilde) if accepted: lattice = new_lattice lattice_full[:, :, x] = lattice size_z = lattice_full.shape[2] lattice3D = lattice_full[:, :, size_z - n_usable_configs:size_z] return lattice3D
""" A simple program that will import your tests and run them all! Be sure you include tests for your other modules like cells and player! Usage: python3 test_all.py """ import subprocess from test_game import run_tests as test_game from test_grid import run_tests as test_grid from test_parser import run_tests as test_parser print("###########################") print("### Running unit tests! ###") print("###########################\n") test_game() test_grid() test_parser() # Run the e2e script subprocess.call(['./test_e2e.sh'])