Skip to content

Commit c3c3452

Browse files
Apply ruff/refurb preview rule FURB145
FURB145 Prefer `copy` method over slicing
1 parent 2c1cf76 commit c3c3452

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

0 commit comments

Comments
 (0)