From f9eba7b5126c0f351d56dd3d302a078265ab1702 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:00:45 +0200 Subject: [PATCH] STY: Apply ruff/flake8-comprehensions rule C416 C416 Unnecessary `dict` comprehension (rewrite using `dict()`) --- nibabel/brikhead.py | 2 +- nibabel/nicom/dicomwrappers.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/nibabel/brikhead.py b/nibabel/brikhead.py index da8692efd..d187a6b34 100644 --- a/nibabel/brikhead.py +++ b/nibabel/brikhead.py @@ -198,7 +198,7 @@ def parse_AFNI_header(fobj): return parse_AFNI_header(src) # unpack variables in HEAD file head = fobj.read().split('\n\n') - return {key: value for key, value in map(_unpack_var, head)} + return dict(map(_unpack_var, head)) class AFNIArrayProxy(ArrayProxy): diff --git a/nibabel/nicom/dicomwrappers.py b/nibabel/nicom/dicomwrappers.py index 3842248fd..009880e49 100755 --- a/nibabel/nicom/dicomwrappers.py +++ b/nibabel/nicom/dicomwrappers.py @@ -685,9 +685,7 @@ def __init__(self, dcm_data, frame_filters=None): frame_slc_pos = [np.inner(ipp, self.slice_normal) for ipp in frame_ipps] rnd_slc_pos = np.round(frame_slc_pos, 4) uniq_slc_pos = np.unique(rnd_slc_pos) - pos_ord_map = { - val: order for val, order in zip(uniq_slc_pos, np.argsort(uniq_slc_pos)) - } + pos_ord_map = dict(zip(uniq_slc_pos, np.argsort(uniq_slc_pos))) self._frame_slc_ord = [pos_ord_map[pos] for pos in rnd_slc_pos] if len(self._frame_slc_ord) > 1: self._slice_spacing = (