def store_parallel(self, processes): keys = [] for a in range(self.matrix_size): for b in range(self.matrix_size): for c in range(self.matrix_size): for d in range(self.matrix_size): if not (a > b or c > d or a > c or (a == c and b > d)): keys.append((a, b, c, d)) pool = Pool(processes) values = pool.starmap(self.calculate, keys) repulsion_dict = dict(zip(keys, values)) repulsion_matrix = np.zeros((self.matrix_size, self.matrix_size, self.matrix_size, self.matrix_size)) for a in range(self.matrix_size): for b in range(self.matrix_size): for c in range(self.matrix_size): for d in range(self.matrix_size): repulsion_matrix.itemset((a, b, c, d), repulsion_dict[Symmetry.sort(a, b, c, d)]) return repulsion_matrix
def test_sort_indices_1(self): out = Symmetry.sort(6, 2, 1, 0) testing.assert_array_equal(out, (0, 1, 2, 6))
def test_sort_indices_9(self): out = Symmetry.sort(1, 1, 0, 2) testing.assert_array_equal(out, (0, 2, 1, 1))
def test_sort_indices_8(self): out = Symmetry.sort(2, 1, 2, 0) testing.assert_array_equal(out, (0, 2, 1, 2))
def test_sort_indices_2(self): out = Symmetry.sort(0, 0, 1, 0) testing.assert_array_equal(out, (0, 0, 0, 1))