#NEWLINE# def savez_compress( file , * args , **kwds ) : #NEWLINE# #INDENT# import zipfile #NEWLINE# import tempfile #NEWLINE# if isinstance ( file , str ) : #NEWLINE# #INDENT# if ( not file . endswith ( '.npz' ) ) : #NEWLINE# #INDENT# file = ( file + '.npz' ) #NEWLINE# #UNINDENT# #UNINDENT# namedict = kwds #NEWLINE# for ( i , val ) in enumerate ( args ) : #NEWLINE# #INDENT# key = ( 'arr_%d' % i ) #NEWLINE# if ( key in namedict ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Cannot use un-named variables and keyword %s' % key ) ) #NEWLINE# #UNINDENT# namedict [ key ] = val #NEWLINE# #UNINDENT# zip = zipfile . ZipFile ( file , mode = 'w' , compression = zipfile . ZIP_DEFLATED ) #NEWLINE# ( fd , tmpfile ) = tempfile . mkstemp ( suffix = '-numpy.npy' ) #NEWLINE# os . close ( fd ) #NEWLINE# try : #NEWLINE# #INDENT# for ( key , val ) in namedict . items ( ) : #NEWLINE# #INDENT# fname = ( key + '.npy' ) #NEWLINE# fid = open ( tmpfile , 'wb' ) #NEWLINE# try : #NEWLINE# #INDENT# np . lib . format . write_array ( fid , np . asanyarray ( val ) ) #NEWLINE# fid . close ( ) #NEWLINE# fid = None #NEWLINE# zip . write ( tmpfile , arcname = fname ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if fid : #NEWLINE# #INDENT# fid . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# os . remove ( tmpfile ) #NEWLINE# #UNINDENT# zip . close ( )