Skip to content

Commit 4d033ed

Browse files
authored
Merge pull request #581 from DimitriPapadopoulos/FURB
Apply ruff/refurb preview rules (FURB)
2 parents f4aa8e4 + 888317e commit 4d033ed

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

nipy/algorithms/utils/pca.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _get_covariance(data, UX, rmse_scales_func, mask):
216216
# If we have more then 2D, then we iterate over slices in the second
217217
# dimension, in order to save memory
218218
slices = [slice(i,i+1) for i in range(data.shape[1])]
219-
for i, s_slice in enumerate(slices):
219+
for s_slice in slices:
220220
Y = data[:,s_slice].reshape((n_pts, -1))
221221
# project data into required space
222222
YX = np.dot(UX, Y)

nipy/algorithms/utils/tests/test_pca_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def test_other_axes(data_dict):
302302
assert_almost_equal(pos_dp['basis_vectors'], pos_p[bv_key])
303303
assert_almost_equal(pos_dp['basis_projections'], img_bps.get_fdata())
304304
# And we've replaced the expected axis
305-
exp_coords = in_coords[:]
305+
exp_coords = in_coords.copy()
306306
exp_coords[exp_coords.index(axis_name)] = 'PCA components'
307307
assert img_bps.axes.coord_names == tuple(exp_coords)
308308
# If the affine is not diagonal, we'll get an error
@@ -323,6 +323,6 @@ def test_other_axes(data_dict):
323323
pytest.raises(AxisError, pca_image, nd_img, axis_name)
324324
for axis_name in 'kt':
325325
p = pca_image(img, axis_name, ncomp=ncomp)
326-
exp_coords = in_coords[:]
326+
exp_coords = in_coords.copy()
327327
exp_coords[exp_coords.index(axis_name)] = 'PCA components'
328328
assert p['basis_projections'].axes.coord_names == tuple(exp_coords)

nipy/core/utils/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def slice_generator(data, axis=0):
182182
slice_template = [slice(0, s) for s in data.shape]
183183

184184
for n in range(nmax):
185-
slices = slice_template[:]
185+
slices = slice_template.copy()
186186
for (a, div, mod) in zip(axis, divs, mods):
187187
x = int(n / div % mod)
188188
slices[a] = x

nipy/labs/mask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def compute_mask_sessions(session_images, m=0.2, M=0.9, cc=1, threshold=0.5,
293293
The mean image
294294
"""
295295
mask, mean = None, None
296-
for index, session in enumerate(session_images):
296+
for session in session_images:
297297
if hasattr(session, 'get_fdata'):
298298
mean = session.get_fdata()
299299
if mean.ndim > 3:

nipy/modalities/fmri/tests/test_glm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def write_fake_fmri_data(shapes, rk=3, affine=np.eye(4)):
3737
def generate_fake_fmri_data(shapes, rk=3, affine=np.eye(4)):
3838
fmri_data = []
3939
design_matrices = []
40-
for i, shape in enumerate(shapes):
40+
for shape in shapes:
4141
data = 100 + np.random.randn(*shape)
4242
data[0] -= 10
4343
fmri_data.append(Nifti1Image(data, affine))

0 commit comments

Comments
 (0)