#NEWLINE# def save_obj( obj , save_path ) : #NEWLINE# #INDENT# '\n    Dumps a python data structure to a saved on-disk representation.  We\n    currently support writing to the following file formats (expected filename\n    extension in brackets):\n\n        * python pickle (.pkl)\n\n    Arguments:\n        obj (object): the python object to be saved.\n        save_path (str): Where to write the serialized object (full path and\n                         file name)\n\n    See Also:\n        :py:func:`~neon.models.model.Model.serialize`\n    ' #NEWLINE# if ( ( save_path is None ) or ( len ( save_path ) == 0 ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# save_path = os . path . expandvars ( os . path . expanduser ( save_path ) ) #NEWLINE# logger . debug ( 'serializing object to: %s' , save_path ) #NEWLINE# ensure_dirs_exist ( save_path ) #NEWLINE# pickle . dump ( obj , open ( save_path , 'wb' ) , ( - 1 ) )