Skip to content

Commit 09ed35e

Browse files
authored
Merge pull request #579 from DimitriPapadopoulos/SIM
Apply ruff/flake8-simplify rules (SIM)
2 parents ccd12f7 + 21c58c8 commit 09ed35e

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

nipy/algorithms/registration/optimizer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,4 @@ def configure_optimizer(optimizer, fprime=None, fhess=None, **kwargs):
4646

4747

4848
def use_derivatives(optimizer):
49-
if optimizer in ('simplex', 'powell'):
50-
return False
51-
else:
52-
return True
49+
return optimizer not in ('simplex', 'powell')

nipy/algorithms/statistics/models/regression.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ def has_intercept(self):
264264
o = np.ones(self.design.shape[0])
265265
obeta = np.dot(self.calc_beta, o)
266266
ohat = np.dot(self.wdesign, obeta)
267-
if np.allclose(ohat, o):
268-
return True
269-
return False
267+
return np.allclose(ohat, o)
270268

271269
@cached_property
272270
def rank(self):
@@ -872,6 +870,4 @@ def isestimable(C, D):
872870
if C.shape[1] != D.shape[1]:
873871
raise ValueError('Contrast should have %d columns' % D.shape[1])
874872
new = np.vstack([C, D])
875-
if matrix_rank(new) != matrix_rank(D):
876-
return False
877-
return True
873+
return matrix_rank(new) == matrix_rank(D)

nipy/io/nifti_ref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def nifti2nipy(ni_img):
580580
if ndim == 3:
581581
return Image(data, cmap3, {'header': hdr})
582582
space_units, time_like_units = hdr.get_xyzt_units()
583-
units_info = TIME_LIKE_UNITS.get(time_like_units, None)
583+
units_info = TIME_LIKE_UNITS.get(time_like_units)
584584
n_ns = ndim - 3
585585
ns_zooms = list(hdr.get_zooms()[3:])
586586
ns_trans = [0] * n_ns

nipy/io/tests/test_nibcompat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_unscaled_data(in_tmp_path):
4242
header = get_header(img_back)
4343
dao = get_dataobj(img_back)
4444
slope = header['scl_slope']
45-
inter = (0. if 'scl_inter' not in header else header['scl_inter'])
45+
inter = (header.get('scl_inter', 0.0))
4646
if np.isnan(slope):
4747
slope, inter = dao.slope, dao.inter
4848
data_back = np.array(dao)

0 commit comments

Comments
 (0)