@@ -526,11 +526,8 @@ def array_from_file(shape, in_dtype, infile, offset=0, order='F', mmap=True):
526
526
n_read = len (data_bytes )
527
527
needs_copy = True
528
528
if n_bytes != n_read :
529
- raise IOError ('Expected {0} bytes, got {1} bytes from {2}\n '
530
- ' - could the file be damaged?' .format (
531
- n_bytes ,
532
- n_read ,
533
- getattr (infile , 'name' , 'object' )))
529
+ raise IOError (f"Expected { n_bytes } bytes, got { n_read } bytes from "
530
+ f"{ getattr (infile , 'name' , 'object' )} \n - could the file be damaged?" )
534
531
arr = np .ndarray (shape , in_dtype , buffer = data_bytes , order = order )
535
532
if needs_copy :
536
533
return arr .copy ()
@@ -747,10 +744,8 @@ def array_to_file(data, fileobj, out_dtype=None, offset=0,
747
744
# nan_fill can be (just) outside clip range
748
745
nan_fill = np .clip (nan_fill , both_mn , both_mx )
749
746
else :
750
- raise ValueError ("nan_fill == {0}, outside safe int range "
751
- "({1}-{2}); change scaling or "
752
- "set nan2zero=False?" .format (
753
- nan_fill , int (both_mn ), int (both_mx )))
747
+ raise ValueError (f"nan_fill == { nan_fill } , outside safe int range "
748
+ f"({ int (both_mn )} -{ int (both_mx )} ); change scaling or set nan2zero=False?" )
754
749
# Make sure non-nan output clipped to shared range
755
750
post_mn = np .max ([post_mn , both_mn ])
756
751
post_mx = np .min ([post_mx , both_mx ])
0 commit comments