Skip to content

Commit 406e27a

Browse files
STY: Further simplification
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 92a0679 commit 406e27a

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

nibabel/tests/test_nifti1.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,7 @@ def test_slice_times(self):
538538
hdr.set_slice_duration(0.1)
539539
# We need a function to print out the Nones and floating point
540540
# values in a predictable way, for the tests below.
541-
_stringer = lambda val: (val is not None and f'{val:2.1f}') or None
542-
_print_me = lambda s: list(map(_stringer, s))
541+
_print_me = lambda s: [val if val is None else f'{val:2.1f}' for val in s]
543542
# The following examples are from the nifti1.h documentation.
544543
hdr['slice_code'] = slice_order_codes['sequential increasing']
545544
assert _print_me(hdr.get_slice_times()) == [

nibabel/tests/test_volumeutils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,7 @@ def test_a2f_nanpos():
607607

608608
def test_a2f_bad_scaling():
609609
# Test that pathological scalers raise an error
610-
NUMERICAL_TYPES = [
611-
x
612-
for sublist in (sctypes[key] for key in ('int', 'uint', 'float', 'complex'))
613-
for x in sublist
614-
]
610+
NUMERICAL_TYPES = [tp for kind in ('int', 'uint', 'float', 'complex') for tp in sctypes[kind]]
615611
for in_type, out_type, slope, inter in itertools.product(
616612
NUMERICAL_TYPES,
617613
NUMERICAL_TYPES,

nibabel/volumeutils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
DT = ty.TypeVar('DT', bound=np.generic)
3636

3737
sys_is_le = sys.byteorder == 'little'
38-
native_code = (sys_is_le and '<') or '>'
39-
swapped_code = (sys_is_le and '>') or '<'
38+
native_code, swapped_code = ('<', '>') if sys_is_le else ('>', '<')
4039

4140
_endian_codes = ( # numpy code, aliases
4241
('<', 'little', 'l', 'le', 'L', 'LE'),

0 commit comments

Comments
 (0)