Skip to content

Commit 5c774dc

Browse files
committed
ENH: Switch from predicate/and/or to if/predicate/else
1 parent 7e5d584 commit 5c774dc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

nibabel/cmdline/dicomfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def main(args=None):
231231

232232
if opts.verbose:
233233
logger.addHandler(logging.StreamHandler(sys.stdout))
234-
logger.setLevel(opts.verbose > 1 and logging.DEBUG or logging.INFO)
234+
logger.setLevel(logging.DEBUG if opts.verbose > 1 else logging.INFO)
235235

236236
if len(files) != 2:
237237
sys.stderr.write(f'Please provide two arguments:\n{parser.usage}\n')

nibabel/tests/test_nifti1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +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
541+
_stringer = lambda val: f'{val:2.1f}' if val is not None else None
542542
_print_me = lambda s: list(map(_stringer, s))
543543
# The following examples are from the nifti1.h documentation.
544544
hdr['slice_code'] = slice_order_codes['sequential increasing']

nibabel/volumeutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
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 = '<' if sys_is_le else '>'
39+
swapped_code = '>' if sys_is_le else '<'
4040

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

0 commit comments

Comments
 (0)