Skip to content

Commit a68105c

Browse files
committed
use copy=False and filter warnings now that PRs are open in VTK and nitime
1 parent 683a168 commit a68105c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+76
-73
lines changed

mne/_fiff/_digitization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _get_data_as_dict_from_dig(dig, exclude_ref_channel=True):
335335
f"Only single coordinate frame in dig is supported, got {dig_coord_frames}"
336336
)
337337
dig_ch_pos_location = np.array(dig_ch_pos_location)
338-
dig_ch_pos_location = dig_ch_pos_location.reshape(-1, 3) # empty will be (0, 3)
338+
dig_ch_pos_location = dig_ch_pos_location.reshape((-1, 3), copy=False)
339339
return Bunch(
340340
nasion=fids.get("nasion", None),
341341
lpa=fids.get("lpa", None),

mne/_fiff/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _read_matrix(fid, tag, shape, rlims):
177177
data = data.view(">c8")
178178
elif matrix_type == FIFF.FIFFT_COMPLEX_DOUBLE:
179179
data = data.view(">c16")
180-
data = data.reshape(dims)
180+
data = data.reshape(dims, copy=False)
181181
else:
182182
# Find dimensions and return to the beginning of tag data
183183
ndim = int(np.frombuffer(fid.read(4), dtype=">i4").item())

mne/beamformer/_rap_music.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def _apply_rap_music(
6868
phi_sig = eig_vectors[:, -n_dipoles:]
6969

7070
n_orient = 3 if is_free_ori else 1
71-
G = G.reshape(G.shape[0], -1, n_orient)
71+
G = G.reshape((G.shape[0], -1, n_orient), copy=False)
7272
gain = forward["sol"]["data"].copy()
73-
gain = gain.reshape(G.shape)
73+
gain = gain.reshape(G.shape, copy=False)
7474
n_channels = G.shape[0]
7575
A = np.empty((n_channels, n_dipoles))
7676
gain_dip = np.empty((n_channels, n_dipoles))
@@ -122,7 +122,7 @@ def _apply_rap_music(
122122
sol = linalg.lstsq(A, M)[0]
123123
if n_orient == 3:
124124
X = sol[:, np.newaxis] * oris[:, :, np.newaxis]
125-
X = X.reshape(-1, len(times))
125+
X = X.reshape((-1, len(times)), copy=False)
126126
else:
127127
X = sol
128128

mne/beamformer/tests/test_dics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def test_make_dics(tmp_path, _load_forward, idx, whiten):
269269
exp=None,
270270
noise_cov=noise_cov,
271271
)
272-
G = G.reshape(n_channels, n_verts, n_orient)
272+
G = G.reshape((n_channels, n_verts, n_orient), copy=False)
273273
G = G.transpose(1, 2, 0).conj() # verts, orient, ch
274274
_assert_weight_norm(filters, G)
275275

mne/beamformer/tests/test_external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_lcmv_fieldtrip(_get_bf_data, bf_type, weight_norm, pick_ori, pwr):
9898
ft_fname = ft_data_path / ("ft_source_" + bf_type + "-vol.mat")
9999
stc_ft_data = pymatreader.read_mat(ft_fname)["stc"]
100100
if stc_ft_data.ndim == 1:
101-
stc_ft_data = stc_ft_data.reshape(stc_ft_data.size, 1)
101+
stc_ft_data = stc_ft_data.reshape((stc_ft_data.size, 1), copy=False)
102102

103103
if stc_mne.data.ndim == 2:
104104
signs = np.sign((stc_mne.data * stc_ft_data).sum(-1, keepdims=True))

mne/beamformer/tests/test_lcmv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ def test_unit_noise_gain_formula(pick_ori, weight_norm, reg, inversion):
11851185
)
11861186
n_channels, n_sources = G.shape
11871187
n_sources //= 3
1188-
G = G.reshape(n_channels, n_sources, 3)
1188+
G = G.reshape((n_channels, n_sources, 3), copy=False)
11891189
G = G.transpose(1, 2, 0) # verts, orient, ch
11901190
_assert_weight_norm(filters, G)
11911191

mne/channels/montage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,9 @@ def read_dig_hpts(fname, unit="mm"):
973973
label[ii]: this_xyz for ii, this_xyz in enumerate(xyz) if kind[ii] == "eeg"
974974
}
975975
hpi = np.array([this_xyz for ii, this_xyz in enumerate(xyz) if kind[ii] == "hpi"])
976-
hpi = hpi.reshape(-1, 3) # in case it's empty
976+
hpi = hpi.reshape((-1, 3), copy=False) # in case it's empty
977977
hsp = np.array([this_xyz for ii, this_xyz in enumerate(xyz) if kind[ii] == "extra"])
978-
hsp = hsp.reshape(-1, 3) # in case it's empty
978+
hsp = hsp.reshape((-1, 3), copy=False) # in case it's empty
979979
return make_dig_montage(ch_pos=ch_pos, **fid, hpi=hpi, hsp=hsp)
980980

981981

mne/chpi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def read_head_pos(fname):
117117
"""
118118
_check_fname(fname, must_exist=True, overwrite="read")
119119
data = np.loadtxt(fname, skiprows=1) # first line is header, skip it
120-
data = data.reshape(-1, 10) # ensure it's the right size even if empty
120+
data = data.reshape((-1, 10), copy=False) # ensure it's the right size even if empty
121121
if np.isnan(data).any(): # make sure we didn't do something dumb
122122
raise RuntimeError(f"positions could not be read properly from {fname}")
123123
return data
@@ -1390,7 +1390,7 @@ def compute_chpi_locs(
13901390
)
13911391
fwd = _magnetic_dipole_field_vec(guesses, meg_coils, too_close)
13921392
fwd = np.dot(fwd, whitener.T)
1393-
fwd = fwd.reshape(guesses.shape[0], 3, -1)
1393+
fwd = fwd.reshape((guesses.shape[0], 3, -1), copy=False)
13941394
fwd = np.linalg.svd(fwd, full_matrices=False)[2]
13951395
guesses = dict(rr=guesses, whitened_fwd_svd=fwd)
13961396
del fwd, R

mne/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ def pytest_configure(config: pytest.Config):
207207
ignore:^'.*' deprecated - use '.*'$:DeprecationWarning
208208
# dipy
209209
ignore:'where' used without 'out', expect .*:UserWarning
210+
# VTK <-> NumPy 2.5 (https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12796)
211+
# nitime <-> NumPy 2.5 (https://github.com/nipy/nitime/pull/236)
212+
ignore:Setting the shape on a NumPy array has been deprecated.*:DeprecationWarning
210213
""" # noqa: E501
211214
for warning_line in warning_lines.split("\n"):
212215
warning_line = warning_line.strip()

mne/decoding/receptive_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def predict(self, X):
361361
else:
362362
extra = 1
363363
shape = shape[: self._y_dim + extra]
364-
y_pred = y_pred.reshape(shape)
364+
y_pred = y_pred.reshape(shape, copy=False)
365365
return y_pred
366366

367367
def score(self, X, y):

0 commit comments

Comments
 (0)