@@ -1340,25 +1340,18 @@ def _ftype4scaled_finite(tst_arr, slope, inter, direction='read',
1340
1340
slope = slope .astype (ftype )
1341
1341
inter = inter .astype (ftype )
1342
1342
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 :
1349
1348
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 :
1353
1350
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 :
1358
1353
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 :
1362
1355
tst_trans = tst_trans / slope
1363
1356
# Double-check that result is finite
1364
1357
if np .all (np .isfinite (tst_trans )):
0 commit comments