source: branches/UQ/pickle.py @ 855

Revision 855, 716 bytes checked in by mmckerns, 5 months ago (diff)

updated copyright to 2016

Line 
1#!/usr/bin/env python
2#
3# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4# Copyright (c) 2009-2016 California Institute of Technology.
5# License: 3-clause BSD.  The full license text is available at:
6#  - http://mmckerns.github.io/project/mystic/browser/mystic/LICENSE
7
8def tmp_pickle(func, suffix='.pik'):
9    """ standard pickle.dump of function to a NamedTemporaryFile """
10    import dill as pickle
11    import tempfile
12    file = tempfile.NamedTemporaryFile(suffix=suffix, dir='.')
13    pickle.dump(func, file)
14    file.flush()
15    return file
16
17
18def unpickle(filename):
19  """ standard pickle.load of function from a File """
20  import dill as pickle
21  return pickle.load(open(filename,'r'))
22
23
Note: See TracBrowser for help on using the repository browser.