Python numpy.repeat() Examples
The following are 30
code examples of numpy.repeat().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: reppoints_head.py From mmdetection with Apache License 2.0 | 6 votes |
def offset_to_pts(self, center_list, pred_list): """Change from point offset to point coordinate.""" pts_list = [] for i_lvl in range(len(self.point_strides)): pts_lvl = [] for i_img in range(len(center_list)): pts_center = center_list[i_img][i_lvl][:, :2].repeat( 1, self.num_points) pts_shift = pred_list[i_lvl][i_img] yx_pts_shift = pts_shift.permute(1, 2, 0).view( -1, 2 * self.num_points) y_pts_shift = yx_pts_shift[..., 0::2] x_pts_shift = yx_pts_shift[..., 1::2] xy_pts_shift = torch.stack([x_pts_shift, y_pts_shift], -1) xy_pts_shift = xy_pts_shift.view(*yx_pts_shift.shape[:-1], -1) pts = xy_pts_shift * self.point_strides[i_lvl] + pts_center pts_lvl.append(pts) pts_lvl = torch.stack(pts_lvl, 0) pts_list.append(pts_lvl) return pts_list
Example #2
Source File: vfn_eval.py From view-finding-network with GNU General Public License v3.0 | 6 votes |
def evaluate_sliding_window(img_filename, crops): img = io.imread(img_filename).astype(np.float32)/255 if img.ndim == 2: # Handle B/W images img = np.expand_dims(img, axis=-1) img = np.repeat(img, 3, 2) img_crops = np.zeros((batch_size, 227, 227, 3)) for i in xrange(len(crops)): crop = crops[i] img_crop = transform.resize(img[crop[1]:crop[1]+crop[3],crop[0]:crop[0]+crop[2]], (227, 227))-0.5 img_crop = np.expand_dims(img_crop, axis=0) img_crops[i,:,:,:] = img_crop # compute ranking scores scores = sess.run([score_func], feed_dict={image_placeholder: img_crops}) # find the optimal crop idx = np.argmax(scores[:len(crops)]) best_window = crops[idx] # return the best crop return (best_window[0], best_window[1], best_window[2], best_window[3])
Example #3
Source File: pano_lsd_align.py From HorizonNet with MIT License | 6 votes |
def computeUVN_vec(n, in_, planeID): ''' vectorization version of computeUVN @n N x 3 @in_ MN x 1 @planeID N ''' n = n.copy() if (planeID == 2).sum(): n[planeID == 2] = np.roll(n[planeID == 2], 2, axis=1) if (planeID == 3).sum(): n[planeID == 3] = np.roll(n[planeID == 3], 1, axis=1) n = np.repeat(n, in_.shape[0] // n.shape[0], axis=0) assert n.shape[0] == in_.shape[0] bc = n[:, [0]] * np.sin(in_) + n[:, [1]] * np.cos(in_) bs = n[:, [2]] out = np.arctan(-bc / (bs + 1e-9)) return out
Example #4
Source File: deform.py From dataflow with Apache License 2.0 | 6 votes |
def np_sample(img, coords): # a numpy implementation of ImageSample layer coords = np.maximum(coords, 0) coords = np.minimum(coords, np.array([img.shape[0] - 1, img.shape[1] - 1])) lcoor = np.floor(coords).astype('int32') ucoor = lcoor + 1 ucoor = np.minimum(ucoor, np.array([img.shape[0] - 1, img.shape[1] - 1])) diff = coords - lcoor neg_diff = 1.0 - diff lcoory, lcoorx = np.split(lcoor, 2, axis=2) ucoory, ucoorx = np.split(ucoor, 2, axis=2) diff = np.repeat(diff, 3, 2).reshape((diff.shape[0], diff.shape[1], 2, 3)) neg_diff = np.repeat(neg_diff, 3, 2).reshape((diff.shape[0], diff.shape[1], 2, 3)) diffy, diffx = np.split(diff, 2, axis=2) ndiffy, ndiffx = np.split(neg_diff, 2, axis=2) ret = img[lcoory, lcoorx, :] * ndiffx * ndiffy + \ img[ucoory, ucoorx, :] * diffx * diffy + \ img[lcoory, ucoorx, :] * ndiffy * diffx + \ img[ucoory, lcoorx, :] * diffy * ndiffx return ret[:, :, 0, :]
Example #5
Source File: metrics_test.py From fine-lm with MIT License | 6 votes |
def testMultilabelMatch3(self): predictions = np.random.randint(1, 5, size=(100, 1, 1, 1)) targets = np.random.randint(1, 5, size=(100, 10, 1, 1)) weights = np.random.randint(0, 2, size=(100, 1, 1, 1)) targets *= weights predictions_repeat = np.repeat(predictions, 10, axis=1) expected = (predictions_repeat == targets).astype(float) expected = np.sum(expected, axis=(1, 2, 3)) expected = np.minimum(expected / 3.0, 1.) expected = np.sum(expected * weights[:, 0, 0, 0]) / weights.shape[0] with self.test_session() as session: scores, weights_ = metrics.multilabel_accuracy_match3( tf.one_hot(predictions, depth=5, dtype=tf.float32), tf.constant(targets, dtype=tf.int32)) a, a_op = tf.metrics.mean(scores, weights_) session.run(tf.local_variables_initializer()) session.run(tf.global_variables_initializer()) _ = session.run(a_op) actual = session.run(a) self.assertAlmostEqual(actual, expected, places=6)
Example #6
Source File: data_loader.py From Keras-GAN with MIT License | 6 votes |
def setup_mnist(self, img_res): print ("Setting up MNIST...") if not os.path.exists('datasets/mnist_x.npy'): # Load the dataset (mnist_X, mnist_y), (_, _) = mnist.load_data() # Normalize and rescale images mnist_X = self.normalize(mnist_X) mnist_X = np.array([imresize(x, img_res) for x in mnist_X]) mnist_X = np.expand_dims(mnist_X, axis=-1) mnist_X = np.repeat(mnist_X, 3, axis=-1) self.mnist_X, self.mnist_y = mnist_X, mnist_y # Save formatted images np.save('datasets/mnist_x.npy', self.mnist_X) np.save('datasets/mnist_y.npy', self.mnist_y) else: self.mnist_X = np.load('datasets/mnist_x.npy') self.mnist_y = np.load('datasets/mnist_y.npy') print ("+ Done.")
Example #7
Source File: group_assign.py From ncvx with GNU General Public License v3.0 | 6 votes |
def _project(self, matrix): if self.is_scalar(): return 1 else: # Note that we use Munkres algorithm, but expand columns from n to m # by replicating each column by group size. mm = np.repeat(matrix, self.col_sum, axis=1) indexes = lap.lapjv(np.asarray(-mm)) result = np.zeros(self.shape) reduce = np.repeat(range(len(self.col_sum)), self.col_sum) for row, column in enumerate(indexes[1]): # map expanded column index to reduced group index. result[row, reduce[column]] = 1 return result # Constrain all entries to be zero that correspond to # zeros in the matrix.
Example #8
Source File: ModelingCloth.py From Modeling-Cloth with MIT License | 6 votes |
def zxy_grid(co_y, tymin, tymax, subs, c, t, c_peat, t_peat): # create linespace grid between bottom and top of tri z #subs = 7 t_min = np.min(tymin) t_max = np.max(tymax) divs = np.linspace(t_min, t_max, num=subs, dtype=np.float32) # figure out which triangles and which co are in each section co_bools = (co_y > divs[:-1][:, nax]) & (co_y < divs[1:][:, nax]) tri_bools = (tymin < divs[1:][:, nax]) & (tymax > divs[:-1][:, nax]) for i, j in zip(co_bools, tri_bools): if (np.sum(i) > 0) & (np.sum(j) > 0): c3 = c[i] t3 = t[j] c_peat.append(np.repeat(c3, t3.shape[0])) t_peat.append(np.tile(t3, c3.shape[0]))
Example #9
Source File: atari_wrappers.py From chainerrl with MIT License | 6 votes |
def __init__(self, env, k, channel_order='hwc'): """Stack k last frames. Returns lazy array, which is much more memory efficient. See Also -------- baselines.common.atari_wrappers.LazyFrames """ gym.Wrapper.__init__(self, env) self.k = k self.frames = deque([], maxlen=k) self.stack_axis = {'hwc': 2, 'chw': 0}[channel_order] orig_obs_space = env.observation_space low = np.repeat(orig_obs_space.low, k, axis=self.stack_axis) high = np.repeat(orig_obs_space.high, k, axis=self.stack_axis) self.observation_space = spaces.Box( low=low, high=high, dtype=orig_obs_space.dtype)
Example #10
Source File: fisheye.py From DualFisheye with MIT License | 6 votes |
def render_cubemap(self, out_size, mode='blend'): # Create coordinate arrays. cvec = np.arange(out_size, dtype='float32') - out_size/2 # Coordinate range [-S/2, S/2) vec0 = np.ones(out_size*out_size, dtype='float32') * out_size/2 # Constant vector +S/2 vec1 = np.repeat(cvec, out_size) # Increment every N steps vec2 = np.tile(cvec, out_size) # Sweep N times # Create XYZ coordinate vectors and render each cubemap face. render = lambda(xyz): self._render(xyz, out_size, out_size, mode) xm = render(np.matrix([-vec0, vec1, vec2])) # -X face xp = render(np.matrix([vec0, vec1, -vec2])) # +X face ym = render(np.matrix([-vec1, -vec0, vec2])) # -Y face yp = render(np.matrix([vec1, vec0, vec2])) # +Y face zm = render(np.matrix([-vec2, vec1, -vec0])) # -Z face zp = render(np.matrix([vec2, vec1, vec0])) # +Z face # Concatenate the individual faces in canonical order: # https://en.wikipedia.org/wiki/Cube_mapping#Memory_Addressing img_mat = np.concatenate([zp, zm, ym, yp, xm, xp], axis=0) return Image.fromarray(img_mat) # Get XYZ vectors for an equirectangular render, in raster order. # (Each row left to right, with rows concatenates from top to bottom.)
Example #11
Source File: electrode_placement.py From simnibs with GNU General Public License v3.0 | 6 votes |
def _optimize_2D(nodes, triangles, stay=[]): ''' Optimize the locations of the points by moving them towards the center of their patch. This is done iterativally for all points for a number of iterations and using a .05 step length''' edges, tr_edges, adjacency_list = _edge_list(triangles) boundary = edges[adjacency_list[:, 1] == -1].reshape(-1) stay = np.union1d(boundary, stay) stay = stay.astype(int) n_iter = 5 step_length = .05 mean_bar = np.zeros_like(nodes) new_nodes = np.copy(nodes) k = np.bincount(triangles.reshape(-1), minlength=len(nodes)) for n in range(n_iter): bar = np.mean(new_nodes[triangles], axis=1) for i in range(2): mean_bar[:, i] = np.bincount(triangles.reshape(-1), weights=np.repeat(bar[:, i], 3), minlength=len(nodes)) mean_bar /= k[:, None] new_nodes += step_length * (mean_bar - new_nodes) new_nodes[stay] = nodes[stay] return new_nodes
Example #12
Source File: mesh_io.py From simnibs with GNU General Public License v3.0 | 6 votes |
def nodes_areas(self): ''' Areas for all nodes in a surface Returns --------- nd: NodeData NodeData structure with normals for each node ''' areas = self.elements_volumes_and_areas()[self.elm.triangles] triangle_nodes = self.elm[self.elm.triangles, :3] - 1 nd = np.bincount( triangle_nodes.reshape(-1), np.repeat(areas/3., 3), self.nodes.nr ) return NodeData(nd, 'areas')
Example #13
Source File: out_of_bounds_repair.py From pymoo with Apache License 2.0 | 6 votes |
def repair_out_of_bounds_manually(X, xl, xu): only_1d = (X.ndim == 1) X = at_least_2d_array(X) if xl is not None: xl = np.repeat(xl[None, :], X.shape[0], axis=0) X[X < xl] = xl[X < xl] if xu is not None: xu = np.repeat(xu[None, :], X.shape[0], axis=0) X[X > xu] = xu[X > xu] if only_1d: return X[0, :] else: return X
Example #14
Source File: misc.py From simnibs with GNU General Public License v3.0 | 6 votes |
def combvec(arrays, out=None): arrays = [np.asarray(x) for x in arrays] dtype = arrays[0].dtype n = np.prod([x.size for x in arrays]) if out is None: out = np.zeros([n, len(arrays)], dtype=dtype) m = n // arrays[0].size out[:,0] = np.repeat(arrays[0], m) if arrays[1:]: combvec(arrays[1:], out=out[0:m,1:]) for j in range(1, arrays[0].size): out[j*m:(j+1)*m,1:] = out[0:m,1:] return out
Example #15
Source File: mesh_io.py From simnibs with GNU General Public License v3.0 | 5 votes |
def nodes_normals(self, smooth=0): ''' Normals for all nodes in a surface Parameters ------------ smooth: int (optional) Number of smoothing cycles to perform. Default: 0 Returns --------- nd: NodeData NodeData structure with normals for each surface node ''' nodes = np.unique(self.elm[self.elm.triangles, :3]) elements = self.elm.triangles nd = np.zeros((self.nodes.nr, 3)) node_tr = self.nodes[self.elm.node_number_list[elements - 1, :3]] sideA = node_tr[:, 1] - node_tr[:, 0] sideB = node_tr[:, 2] - node_tr[:, 0] normals = np.cross(sideA, sideB) triangle_nodes = self.elm.node_number_list[elements - 1, :3] - 1 for s in range(smooth + 1): for i in range(3): nd[:, i] = \ np.bincount(triangle_nodes.reshape(-1), np.repeat(normals[:, i], 3), self.nodes.nr) normals = np.sum(nd[self.elm.node_number_list[elements - 1, :3] - 1], axis=1) normals /= np.linalg.norm(normals, axis=1)[:, None] nd[nodes - 1] = nd[nodes-1] / \ np.linalg.norm(nd[nodes-1], axis=1)[:, None] return NodeData(nd, 'normals')
Example #16
Source File: vector_frame_stack.py From chainerrl with MIT License | 5 votes |
def __init__(self, env, k, stack_axis=0): """Stack k last frames.""" VectorEnvWrapper.__init__(self, env) self.k = k self.stack_axis = stack_axis self.frames = [deque([], maxlen=k) for _ in range(env.num_envs)] orig_obs_space = env.observation_space assert isinstance(orig_obs_space, spaces.Box) low = np.repeat(orig_obs_space.low, k, axis=self.stack_axis) high = np.repeat(orig_obs_space.high, k, axis=self.stack_axis) self.observation_space = spaces.Box( low=low, high=high, dtype=orig_obs_space.dtype)
Example #17
Source File: mesh_io.py From simnibs with GNU General Public License v3.0 | 5 votes |
def fix_thin_tetrahedra(self, n_iter=7, step_length=.05): ''' Optimize the locations of the points by moving them towards the center of their patch. This is done iterativally for all points for a number of iterations''' vol_before = self.elements_volumes_and_areas()[self.elm.tetrahedra].sum() boundary_faces = [] vol_tags = np.unique(self.elm.tag1[self.elm.elm_type == 4]) for t in vol_tags: th_indexes = self.elm.elm_number[ (self.elm.tag1 == t) * (self.elm.elm_type == 4)] boundary_faces.append( self.elm.get_outside_faces( tetrahedra_indexes=th_indexes)) boundary_faces = np.vstack(boundary_faces) boundary_nodes = np.unique(boundary_faces) - 1 mean_bar = np.zeros_like(self.nodes.node_coord) nodes_bk = np.copy(self.nodes.node_coord) new_nodes = self.nodes.node_coord tetrahedra = self.elm[self.elm.tetrahedra] - 1 k = np.bincount(tetrahedra.reshape(-1), minlength=self.nodes.nr) for n in range(n_iter): bar = np.mean(new_nodes[tetrahedra], axis=1) for i in range(3): mean_bar[:, i] = np.bincount(tetrahedra.reshape(-1), weights=np.repeat(bar[:, i], 4), minlength=self.nodes.nr) mean_bar /= k[:, None] new_nodes += step_length * (mean_bar - new_nodes) new_nodes[boundary_nodes] = nodes_bk[boundary_nodes] self.nodes.node_coord = new_nodes vol_after = self.elements_volumes_and_areas()[self.elm.tetrahedra].sum() # Cheap way of comparing the valitidy of the new trianglulation (assuming the one # in the input is valid) if not np.isclose(vol_before, vol_after): self.nodes.node_coord = nodes_bk
Example #18
Source File: kproxy_supercell.py From pyscf with Apache License 2.0 | 5 votes |
def supercell_response(vind, space, nocc, nmo, double, rot_bloch, log_dest): """ Retrieves a raw response matrix. Args: vind (Callable): a pyscf matvec routine; space (ndarray): the active space: either for both rows and columns (1D array) or for rows and columns separately (2D array). Basis order: [k, orb=o+v]; nocc (ndarray): the numbers of occupied orbitals (frozen and active) per k-point; nmo (ndarray): the total number of orbitals per k-point; double (bool): set to True if `vind` returns the double-sized (i.e. full) matrix; rot_bloch (ndarray): a matrix specifying the rotation from real orbitals returned from pyscf to Bloch functions; log_dest (object): pyscf logging; Returns: The TD matrix. """ if not double: raise NotImplementedError("Not implemented for MK-type matrixes") # Full space dims nmo_full = sum(nmo) space = numpy.array(space) if space.shape == (nmo_full,): space = numpy.repeat(space[numpy.newaxis, :], 2, axis=0) elif space.shape != (2, nmo_full): raise ValueError("The 'space' argument should a 1D array with dimension {:d} or a 2D array with dimensions {}," " found: {}".format(nmo_full, (2, nmo_full), space.shape)) return supercell_response_ov(vind, orb2ov(space, nocc, nmo), nocc, nmo, double, rot_bloch, log_dest)
Example #19
Source File: bounds_back_repair.py From pymoo with Apache License 2.0 | 5 votes |
def _do(self, problem, pop, **kwargs): # bring back to bounds if violated through crossover - bounce back strategy X = pop.get("X") xl = np.repeat(problem.xl[None, :], X.shape[0], axis=0) xu = np.repeat(problem.xu[None, :], X.shape[0], axis=0) # otherwise bounds back into the feasible space _range = xu - xl X[X < xl] = (xl + np.mod((xl - X), _range))[X < xl] X[X > xu] = (xu - np.mod((X - xu), _range))[X > xu] return pop.new("X", X)
Example #20
Source File: coefficient_set.py From risk-slim with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _expand_values(self, value): if isinstance(value, np.ndarray): if value.size == self.P: value_array = value elif value.size == 1: value_array = np.repeat(value, self.P) else: raise ValueError("length mismatch; need either 1 or %d values" % self.P) elif isinstance(value, list): if len(value) == self.P: value_array = value elif len(value) == 1: value_array = [value] * self.P else: raise ValueError("length mismatch; need either 1 or %d values" % self.P) elif isinstance(value, str): value_array = [str(value)] * self.P elif isinstance(value, int): value_array = [int(value)] * self.P elif isinstance(value, float): value_array = [float(value)] * self.P else: raise ValueError("unknown variable type %s") return(value_array)
Example #21
Source File: krohf.py From pyscf with Apache License 2.0 | 5 votes |
def get_init_guess(self, cell=None, key='minao'): if cell is None: cell = self.cell dm_kpts = None key = key.lower() if key == '1e' or key == 'hcore': dm_kpts = self.init_guess_by_1e(cell) elif getattr(cell, 'natm', 0) == 0: logger.info(self, 'No atom found in cell. Use 1e initial guess') dm_kpts = self.init_guess_by_1e(cell) elif key == 'atom': dm = self.init_guess_by_atom(cell) elif key[:3] == 'chk': try: dm_kpts = self.from_chk() except (IOError, KeyError): logger.warn(self, 'Fail to read %s. Use MINAO initial guess', self.chkfile) dm = self.init_guess_by_minao(cell) else: dm = self.init_guess_by_minao(cell) if dm_kpts is None: nkpts = len(self.kpts) # dm[spin,nao,nao] at gamma point -> dm_kpts[spin,nkpts,nao,nao] dm_kpts = np.repeat(dm[:,None,:,:], nkpts, axis=1) ne = np.einsum('xkij,kji->', dm_kpts, self.get_ovlp(cell)).real # FIXME: consider the fractional num_electron or not? This maybe # relates to the charged system. nkpts = len(self.kpts) nelec = float(sum(self.nelec)) if np.any(abs(ne - nelec) > 1e-7*nkpts): logger.debug(self, 'Big error detected in the electron number ' 'of initial guess density matrix (Ne/cell = %g)!\n' ' This can cause huge error in Fock matrix and ' 'lead to instability in SCF for low-dimensional ' 'systems.\n DM is normalized wrt the number ' 'of electrons %g', ne/nkpts, nelec/nkpts) dm_kpts *= nelec / ne return dm_kpts
Example #22
Source File: carbonara.py From gnocchi with Apache License 2.0 | 5 votes |
def std(self): values = self._sum(self._ts['values'], self.counts) / self.counts diff_sq = numpy.square(self._ts['values'] - numpy.repeat(values, self.counts)) bin_sum = numpy.bincount( numpy.repeat(numpy.arange(self.counts.size), self.counts), weights=diff_sq) return make_timeseries(self.tstamps[self.counts > 1], numpy.sqrt(bin_sum[self.counts > 1] / (self.counts[self.counts > 1] - 1)))
Example #23
Source File: carbonara.py From gnocchi with Apache License 2.0 | 5 votes |
def max(self): ordered = self._ts['values'].argsort() uniq_inv = numpy.repeat(numpy.arange(self.counts.size), self.counts) values = numpy.zeros(self.tstamps.size) values[uniq_inv[ordered]] = self._ts['values'][ordered] return make_timeseries(self.tstamps, values)
Example #24
Source File: carbonara.py From gnocchi with Apache License 2.0 | 5 votes |
def min(self): ordered = self._ts['values'].argsort() uniq_inv = numpy.repeat(numpy.arange(self.counts.size), self.counts) values = numpy.zeros(self.tstamps.size) values[uniq_inv[ordered][::-1]] = self._ts['values'][ordered][::-1] return make_timeseries(self.tstamps, values)
Example #25
Source File: carbonara.py From gnocchi with Apache License 2.0 | 5 votes |
def _sum(values, counts): return numpy.bincount( numpy.repeat(numpy.arange(counts.size), counts), weights=values)
Example #26
Source File: rnsga2.py From pymoo with Apache License 2.0 | 5 votes |
def calc_norm_pref_distance(A, B, weights, ideal, nadir): D = np.repeat(A, B.shape[0], axis=0) - np.tile(B, (A.shape[0], 1)) N = ((D / (nadir - ideal)) ** 2) * weights N = np.sqrt(np.sum(N, axis=1) * len(weights)) return np.reshape(N, (A.shape[0], B.shape[0]))
Example #27
Source File: dominator.py From pymoo with Apache License 2.0 | 5 votes |
def calc_domination_matrix(F, _F=None, epsilon=0.0): """ if G is None or len(G) == 0: constr = np.zeros((F.shape[0], F.shape[0])) else: # consider the constraint violation # CV = Problem.calc_constraint_violation(G) # constr = (CV < CV) * 1 + (CV > CV) * -1 CV = Problem.calc_constraint_violation(G)[:, 0] constr = (CV[:, None] < CV) * 1 + (CV[:, None] > CV) * -1 """ if _F is None: _F = F # look at the obj for dom n = F.shape[0] m = _F.shape[0] L = np.repeat(F, m, axis=0) R = np.tile(_F, (n, 1)) smaller = np.reshape(np.any(L + epsilon < R, axis=1), (n, m)) larger = np.reshape(np.any(L > R + epsilon, axis=1), (n, m)) M = np.logical_and(smaller, np.logical_not(larger)) * 1 \ + np.logical_and(larger, np.logical_not(smaller)) * -1 # if cv equal then look at dom # M = constr + (constr == 0) * dom return M
Example #28
Source File: misc.py From pymoo with Apache License 2.0 | 5 votes |
def calc_perpendicular_distance(N, ref_dirs): u = np.tile(ref_dirs, (len(N), 1)) v = np.repeat(N, len(ref_dirs), axis=0) norm_u = np.linalg.norm(u, axis=1) scalar_proj = np.sum(v * u, axis=1) / norm_u proj = scalar_proj[:, None] * u / norm_u[:, None] val = np.linalg.norm(proj - v, axis=1) matrix = np.reshape(val, (len(N), len(ref_dirs))) return matrix
Example #29
Source File: misc.py From pymoo with Apache License 2.0 | 5 votes |
def all_combinations(A, B): u = np.repeat(A, B.shape[0], axis=0) v = np.tile(B, A.shape[0]) return np.column_stack([u, v])
Example #30
Source File: supercell.py From pyqmc with MIT License | 5 votes |
def make_supercell_jastrow(jastrow, S): scale = int(np.round(np.linalg.det(S))) supercell = get_supercell(jastrow._mol, S) newjast = pyqmc.JastrowSpin(supercell, jastrow.a_basis, jastrow.b_basis) newjast.parameters["bcoeff"] = jastrow.parameters["bcoeff"] newjast.parameters["acoeff"] = np.repeat( jastrow.parameters["acoeff"], scale, axis=0 ) return newjast