diff --git a/nipy/algorithms/registration/optimizer.py b/nipy/algorithms/registration/optimizer.py index d52d3b49b..3ba3edfc1 100644 --- a/nipy/algorithms/registration/optimizer.py +++ b/nipy/algorithms/registration/optimizer.py @@ -46,7 +46,4 @@ def configure_optimizer(optimizer, fprime=None, fhess=None, **kwargs): def use_derivatives(optimizer): - if optimizer in ('simplex', 'powell'): - return False - else: - return True + return optimizer not in ('simplex', 'powell') diff --git a/nipy/algorithms/statistics/models/regression.py b/nipy/algorithms/statistics/models/regression.py index 6f72b4113..660babb33 100644 --- a/nipy/algorithms/statistics/models/regression.py +++ b/nipy/algorithms/statistics/models/regression.py @@ -264,9 +264,7 @@ def has_intercept(self): o = np.ones(self.design.shape[0]) obeta = np.dot(self.calc_beta, o) ohat = np.dot(self.wdesign, obeta) - if np.allclose(ohat, o): - return True - return False + return np.allclose(ohat, o) @cached_property def rank(self): @@ -872,6 +870,4 @@ def isestimable(C, D): if C.shape[1] != D.shape[1]: raise ValueError('Contrast should have %d columns' % D.shape[1]) new = np.vstack([C, D]) - if matrix_rank(new) != matrix_rank(D): - return False - return True + return matrix_rank(new) == matrix_rank(D) diff --git a/nipy/io/nifti_ref.py b/nipy/io/nifti_ref.py index 3bc32d976..ff72b1e58 100644 --- a/nipy/io/nifti_ref.py +++ b/nipy/io/nifti_ref.py @@ -580,7 +580,7 @@ def nifti2nipy(ni_img): if ndim == 3: return Image(data, cmap3, {'header': hdr}) space_units, time_like_units = hdr.get_xyzt_units() - units_info = TIME_LIKE_UNITS.get(time_like_units, None) + units_info = TIME_LIKE_UNITS.get(time_like_units) n_ns = ndim - 3 ns_zooms = list(hdr.get_zooms()[3:]) ns_trans = [0] * n_ns diff --git a/nipy/io/tests/test_nibcompat.py b/nipy/io/tests/test_nibcompat.py index f37618eb7..66e5b9867 100644 --- a/nipy/io/tests/test_nibcompat.py +++ b/nipy/io/tests/test_nibcompat.py @@ -42,7 +42,7 @@ def test_unscaled_data(in_tmp_path): header = get_header(img_back) dao = get_dataobj(img_back) slope = header['scl_slope'] - inter = (0. if 'scl_inter' not in header else header['scl_inter']) + inter = (header.get('scl_inter', 0.0)) if np.isnan(slope): slope, inter = dao.slope, dao.inter data_back = np.array(dao)