@@ -526,11 +526,8 @@ def array_from_file(shape, in_dtype, infile, offset=0, order='F', mmap=True):
526526 n_read = len (data_bytes )
527527 needs_copy = True
528528 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?" )
534531 arr = np .ndarray (shape , in_dtype , buffer = data_bytes , order = order )
535532 if needs_copy :
536533 return arr .copy ()
@@ -747,10 +744,8 @@ def array_to_file(data, fileobj, out_dtype=None, offset=0,
747744 # nan_fill can be (just) outside clip range
748745 nan_fill = np .clip (nan_fill , both_mn , both_mx )
749746 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?" )
754749 # Make sure non-nan output clipped to shared range
755750 post_mn = np .max ([post_mn , both_mn ])
756751 post_mx = np .min ([post_mx , both_mx ])
0 commit comments