@docfiller
def savemat(file_name, mdict, appendmat=True, format='5', long_field_names=False, do_compression=False, oned_as='row'):
 file_is_string = isinstance(file_name, string_types)
 if file_is_string:
  if (appendmat and (file_name[(-4):] != '.mat')):
   file_name = (file_name + '.mat')
  file_stream = open(file_name, 'wb')
 else:
  if (not hasattr(file_name, 'write')):
   raise IOError('Writer needs file name or writeable file-like object')
  file_stream = file_name
 if (format == '4'):
  if long_field_names:
   raise ValueError('Long field names are not available for version 4 files')
  MW = MatFile4Writer(file_stream, oned_as)
 elif (format == '5'):
  MW = MatFile5Writer(file_stream, do_compression=do_compression, unicode_strings=True, long_field_names=long_field_names, oned_as=oned_as)
 else:
  raise ValueError("Format should be '4' or '5'")
 MW.put_variables(mdict)
 if file_is_string:
  file_stream.close()

@ docfiller def savemat ( file_name , mdict , appendmat = True , format = '5' , long_field_names = False , do_compression = False , oned_as = 'row' ) : file_is_string = isinstance ( file_name , string_types ) if file_is_string : if ( appendmat and ( file_name [ ( - 4 ) : ] != '.mat' ) ) : file_name = ( file_name + '.mat' ) file_stream = open ( file_name , 'wb' ) else : if ( not hasattr ( file_name , 'write' ) ) : raise IOError ( 'Writer needs file name or writeable file-like object' ) file_stream = file_name if ( format == '4' ) : if long_field_names : raise ValueError ( 'Long field names are not available for version 4 files' ) MW = MatFile4Writer ( file_stream , oned_as ) elif ( format == '5' ) : MW = MatFile5Writer ( file_stream , do_compression = do_compression , unicode_strings = True , long_field_names = long_field_names , oned_as = oned_as ) else : raise ValueError ( "Format should be '4' or '5'" ) MW . put_variables ( mdict ) if file_is_string : file_stream . close ( )
save a dictionary of names and arrays into a matlab-style .