Skip to content

Commit

Permalink
FIX: More
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Mar 2, 2024
1 parent b43191c commit 69ce5ff
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mne/forward/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _block_diag(A, n):
jj = jj * np.ones(ma, dtype=np.int64)[:, None]
jj = jj.T.ravel() # column indices foreach sparse bd

bd = sparse.coo_matrix((A.T.ravel(), np.c_[ii, jj].T)).tocsc()
bd = sparse.coo_matrix((A.T.ravel(), np.c_[ii, jj].T), copy=True).tocsc()

return bd

Expand Down
2 changes: 1 addition & 1 deletion mne/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ def _labels_to_stc_surf(labels, values, tmin, tstep, subject):
data[hemi] = np.concatenate(data[hemi], axis=0).astype(float)
cols = np.arange(len(vertices[hemi]))
vertices[hemi], rows = np.unique(vertices[hemi], return_inverse=True)
mat = sparse.coo_matrix((np.ones(len(rows)), (rows, cols))).tocsr()
mat = sparse.coo_matrix((np.ones(len(rows)), (rows, cols)), copy=True).tocsr()
mat = mat * sparse.diags(1.0 / np.asarray(mat.sum(axis=-1))[:, 0])
data[hemi] = mat.dot(data[hemi])
vertices = [vertices[hemi] for hemi in hemis]
Expand Down
2 changes: 1 addition & 1 deletion mne/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _compute_sparse_morph(vertices_from, subject_from, subject_to, subjects_dir=
rows = np.arange(len(cols))
data = np.ones(len(cols))
morph_mat = sparse.coo_matrix(
(data, (rows, cols)), shape=(len(cols), len(cols))
(data, (rows, cols)), shape=(len(cols), len(cols)), copy=True
).tocsr()
return vertices, morph_mat

Expand Down
4 changes: 3 additions & 1 deletion mne/source_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,9 @@ def _get_adjacency_from_edges(edges, n_times, verbose=None):
data = np.ones(
edges.data.size * n_times + 2 * n_vertices * (n_times - 1), dtype=np.int64
)
adjacency = sparse.coo_matrix((data, (row, col)), shape=(n_times * n_vertices,) * 2)
adjacency = sparse.coo_matrix(
(data, (row, col)), shape=(n_times * n_vertices,) * 2, copy=True
)
return adjacency


Expand Down
4 changes: 3 additions & 1 deletion mne/stats/_adjacency.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,7 @@ def combine_adjacency(*structure):
# Handle the diagonal separately at the end to avoid duplicate entries
edges[:, n_off:] = vertices.ravel()
weights[n_off:] = 1.0
graph = sparse.coo_matrix((weights, edges), (vertices.size, vertices.size))
graph = sparse.coo_matrix(
(weights, edges), (vertices.size, vertices.size), copy=True
)
return graph
8 changes: 5 additions & 3 deletions mne/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def _triangle_neighbors(tris, npts):
rows = tris.ravel()
cols = np.repeat(np.arange(len(tris)), 3)
data = np.ones(len(cols))
csr = coo_matrix((data, (rows, cols)), shape=(npts, len(tris))).tocsr()
csr = coo_matrix((data, (rows, cols)), shape=(npts, len(tris)), copy=True).tocsr()
neighbor_tri = [
csr.indices[start:stop] for start, stop in zip(csr.indptr[:-1], csr.indptr[1:])
]
Expand Down Expand Up @@ -1740,7 +1740,7 @@ def _mesh_edges(tris=None):
a, b, c = tris.T
x = np.concatenate((a, b, c))
y = np.concatenate((b, c, a))
edges = coo_matrix((ones_ntris, (x, y)), shape=(npoints, npoints))
edges = coo_matrix((ones_ntris, (x, y)), shape=(npoints, npoints), copy=True)
edges = edges.tocsr()
edges = edges + edges.T
return edges
Expand Down Expand Up @@ -1768,7 +1768,9 @@ def mesh_dist(tris, vert):

# Euclidean distances between neighboring vertices
dist = np.linalg.norm(vert[edges.row, :] - vert[edges.col, :], axis=1)
dist_matrix = csr_matrix((dist, (edges.row, edges.col)), shape=edges.shape)
dist_matrix = csr_matrix(
(dist, (edges.row, edges.col)), shape=edges.shape, copy=True
)
return dist_matrix


Expand Down

0 comments on commit 69ce5ff

Please sign in to comment.