Skip to content

Apply ruff/flake8-simplify rules (SIM) #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions nipy/algorithms/registration/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
8 changes: 2 additions & 6 deletions nipy/algorithms/statistics/models/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion nipy/io/nifti_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nipy/io/tests/test_nibcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading