Skip to content

Commit

Permalink
STY: Further simplification
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Markiewicz <[email protected]>
  • Loading branch information
DimitriPapadopoulos and effigies committed Oct 9, 2024
1 parent c842d84 commit 50a7fb2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
3 changes: 1 addition & 2 deletions nibabel/tests/test_nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ def test_slice_times(self):
hdr.set_slice_duration(0.1)
# We need a function to print out the Nones and floating point
# values in a predictable way, for the tests below.
_stringer = lambda val: (val is not None and f'{val:2.1f}') or None
_print_me = lambda s: list(map(_stringer, s))
_print_me = lambda s: [val if val is None else f'{val:2.1f}' for val in s]
# The following examples are from the nifti1.h documentation.
hdr['slice_code'] = slice_order_codes['sequential increasing']
assert _print_me(hdr.get_slice_times()) == [
Expand Down
6 changes: 1 addition & 5 deletions nibabel/tests/test_volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,7 @@ def test_a2f_nanpos():

def test_a2f_bad_scaling():
# Test that pathological scalers raise an error
NUMERICAL_TYPES = [
x
for sublist in (sctypes[key] for key in ('int', 'uint', 'float', 'complex'))
for x in sublist
]
NUMERICAL_TYPES = [tp for kind in ('int', 'uint', 'float', 'complex') for tp in sctypes[kind]]
for in_type, out_type, slope, inter in itertools.product(
NUMERICAL_TYPES,
NUMERICAL_TYPES,
Expand Down
3 changes: 1 addition & 2 deletions nibabel/volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
DT = ty.TypeVar('DT', bound=np.generic)

sys_is_le = sys.byteorder == 'little'
native_code = (sys_is_le and '<') or '>'
swapped_code = (sys_is_le and '>') or '<'
native_code, swapped_code = ('<', '>') if sys_is_le else ('>', '<')

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

0 comments on commit 50a7fb2

Please sign in to comment.