diff --git a/doc/users/plots/hrf_different.py b/doc/users/plots/hrf_different.py index b47d79edf..527d047d2 100644 --- a/doc/users/plots/hrf_different.py +++ b/doc/users/plots/hrf_different.py @@ -16,8 +16,8 @@ ta = [0,4,8,12,16]; tb = [2,6,10,14,18] ba = 1; bb = -2 -na = ba * sum([glover.subs(T, T - t) for t in ta]) -nb = bb * sum([afni.subs(T, T - t) for t in tb]) +na = ba * sum(glover.subs(T, T - t) for t in ta) +nb = bb * sum(afni.subs(T, T - t) for t in tb) nav = lambdify_t(na) nbv = lambdify_t(nb) diff --git a/doc/users/plots/neuronal_block.py b/doc/users/plots/neuronal_block.py index f30061598..367544642 100644 --- a/doc/users/plots/neuronal_block.py +++ b/doc/users/plots/neuronal_block.py @@ -14,8 +14,8 @@ ta = [0,4,8,12,16]; tb = [2,6,10,14,18] ba = Symbol('ba'); bb = Symbol('bb'); t = Symbol('t') -fa = sum([Piecewise((0, (t<_t)), ((t-_t)/0.5, (t<_t+0.5)), (1, (t >= _t+0.5))) for _t in ta])*ba -fb = sum([Piecewise((0, (t<_t)), ((t-_t)/0.5, (t<_t+0.5)), (1, (t >= _t+0.5))) for _t in tb])*bb +fa = sum(Piecewise((0, (t<_t)), ((t-_t)/0.5, (t<_t+0.5)), (1, (t >= _t+0.5))) for _t in ta)*ba +fb = sum(Piecewise((0, (t<_t)), ((t-_t)/0.5, (t<_t+0.5)), (1, (t >= _t+0.5))) for _t in tb)*bb N = fa+fb Nn = N.subs(ba,1) diff --git a/doc/users/plots/neuronal_event.py b/doc/users/plots/neuronal_event.py index a16f59e0b..ef2e50b90 100644 --- a/doc/users/plots/neuronal_event.py +++ b/doc/users/plots/neuronal_event.py @@ -14,8 +14,8 @@ ba = Symbol('ba') bb = Symbol('bb') t = Symbol('t') -fa = sum([Heaviside(t - _t) for _t in ta]) * ba -fb = sum([Heaviside(t - _t) for _t in tb]) * bb +fa = sum(Heaviside(t - _t) for _t in ta) * ba +fb = sum(Heaviside(t - _t) for _t in tb) * bb N = fa + fb Nn = N.subs(ba, 1) diff --git a/nipy/algorithms/registration/tests/test_histogram_registration.py b/nipy/algorithms/registration/tests/test_histogram_registration.py index 899b0f48e..f6f045b91 100644 --- a/nipy/algorithms/registration/tests/test_histogram_registration.py +++ b/nipy/algorithms/registration/tests/test_histogram_registration.py @@ -203,7 +203,7 @@ def test_set_fov(): R = HistogramRegistration(I, J) R.set_fov(npoints=np.prod(I.shape)) assert R._from_data.shape == I.shape - half_shape = tuple([I.shape[i] / 2 for i in range(3)]) + half_shape = tuple(I.shape[i] / 2 for i in range(3)) R.set_fov(spacing=(2, 2, 2)) assert R._from_data.shape == half_shape R.set_fov(corner=half_shape) diff --git a/nipy/algorithms/statistics/utils.py b/nipy/algorithms/statistics/utils.py index 99f5f57b6..96b3806ab 100644 --- a/nipy/algorithms/statistics/utils.py +++ b/nipy/algorithms/statistics/utils.py @@ -218,7 +218,7 @@ def cube_with_strides_center(center=[0,0,0], for m in maximal: nm = [vertices[j] for j in m] mm.append(nm) - maximal = [tuple([vertices[j] for j in m]) for m in maximal] + maximal = [tuple(vertices[j] for j in m) for m in maximal] return complex(maximal) diff --git a/nipy/core/reference/array_coords.py b/nipy/core/reference/array_coords.py index 8a56381df..b6182c858 100644 --- a/nipy/core/reference/array_coords.py +++ b/nipy/core/reference/array_coords.py @@ -183,7 +183,7 @@ def from_shape(coordmap, shape): are 'array' coordinates. """ - slices = tuple([slice(0,s,1) for s in shape]) + slices = tuple(slice(0,s,1) for s in shape) return Grid(coordmap)[slices] def __repr__(self): diff --git a/nipy/core/reference/slices.py b/nipy/core/reference/slices.py index ee5bdb3fa..ac5d68454 100644 --- a/nipy/core/reference/slices.py +++ b/nipy/core/reference/slices.py @@ -222,4 +222,4 @@ def bounding_box(coordmap, shape): ((2.0, 31.0), (4.0, 121.0), (6.0, 101.0)) """ e = ArrayCoordMap.from_shape(coordmap, shape) - return tuple([(r.min(), r.max()) for r in e.transposed_values]) + return tuple((r.min(), r.max()) for r in e.transposed_values) diff --git a/nipy/io/tests/test_save.py b/nipy/io/tests/test_save.py index 4a2858eba..8dae8401a 100644 --- a/nipy/io/tests/test_save.py +++ b/nipy/io/tests/test_save.py @@ -85,7 +85,7 @@ def test_save3(in_tmp_path): data = tmp.get_fdata().copy() img2 = api.Image(data, tmp.coordmap, tmp.metadata) del tmp - assert tuple([img.shape[l] for l in [3,2,1,0]]) == img2.shape + assert tuple(img.shape[l] for l in [3,2,1,0]) == img2.shape a = np.transpose(img.get_fdata(), [3,2,1,0]) assert not np.allclose(img.affine, img2.affine) assert np.allclose(a, img2.get_fdata()) diff --git a/nipy/labs/tests/test_statistical_mapping.py b/nipy/labs/tests/test_statistical_mapping.py index 728525e7d..c97538d16 100644 --- a/nipy/labs/tests/test_statistical_mapping.py +++ b/nipy/labs/tests/test_statistical_mapping.py @@ -53,17 +53,17 @@ def test_6(): img = make_surrogate_data() clusters, info = cluster_stats(img, img, height_th=.05, height_control='fdr', cluster_th=0, nulls={}) - print(len(clusters), sum([c['size'] for c in clusters])) + print(len(clusters), sum(c['size'] for c in clusters)) assert len(clusters)==4 def test7(): img = make_surrogate_data() clusters, info = cluster_stats(img, img, height_th=3., height_control='None', cluster_th=0, nulls={}) - nstv = sum([c['size'] for c in clusters]) + nstv = sum(c['size'] for c in clusters) assert nstv==36 def test_8(): img = make_surrogate_data() clusters, info = cluster_stats(img, img, height_th=.001, height_control='fpr', cluster_th=0, nulls={}) - nstv = sum([c['size'] for c in clusters]) + nstv = sum(c['size'] for c in clusters) assert nstv==36 diff --git a/nipy/modalities/fmri/tests/test_glm.py b/nipy/modalities/fmri/tests/test_glm.py index 058c49067..943e7c28f 100644 --- a/nipy/modalities/fmri/tests/test_glm.py +++ b/nipy/modalities/fmri/tests/test_glm.py @@ -166,8 +166,8 @@ def test_glm_ar(): mulm, n, p, q = ar1_glm() assert len(mulm.labels_) == n assert len(mulm.results_) > 1 - tmp = sum([mulm.results_[key].theta.shape[1] - for key in mulm.results_]) + tmp = sum(mulm.results_[key].theta.shape[1] + for key in mulm.results_) assert tmp == n