Skip to content

Commit edfcdf0

Browse files
committed
RF: De-duplicate - the vulnerable window stays small
1 parent 143ab5d commit edfcdf0

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

nibabel/volumeutils.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,25 +1340,18 @@ def _ftype4scaled_finite(tst_arr, slope, inter, direction='read',
13401340
slope = slope.astype(ftype)
13411341
inter = inter.astype(ftype)
13421342
try:
1343-
if direction == 'read': # as in reading of image from disk
1344-
if slope != 1.0:
1345-
# Keep warning contexts small to reduce the odds of a race
1346-
with warnings.catch_warnings():
1347-
# Error on overflows to short circuit the logic
1348-
warnings.filterwarnings(*overflow_filter)
1343+
with warnings.catch_warnings():
1344+
# Error on overflows to short circuit the logic
1345+
warnings.filterwarnings(*overflow_filter)
1346+
if direction == 'read': # as in reading of image from disk
1347+
if slope != 1.0:
13491348
tst_trans = tst_trans * slope
1350-
if inter != 0.0:
1351-
with warnings.catch_warnings():
1352-
warnings.filterwarnings(*overflow_filter)
1349+
if inter != 0.0:
13531350
tst_trans = tst_trans + inter
1354-
elif direction == 'write':
1355-
if inter != 0.0:
1356-
with warnings.catch_warnings():
1357-
warnings.filterwarnings(*overflow_filter)
1351+
elif direction == 'write':
1352+
if inter != 0.0:
13581353
tst_trans = tst_trans - inter
1359-
if slope != 1.0:
1360-
with warnings.catch_warnings():
1361-
warnings.filterwarnings(*overflow_filter)
1354+
if slope != 1.0:
13621355
tst_trans = tst_trans / slope
13631356
# Double-check that result is finite
13641357
if np.all(np.isfinite(tst_trans)):

0 commit comments

Comments
 (0)