Created
December 11, 2012 20:09
-
-
Save roban/4261708 to your computer and use it in GitHub Desktop.
copy pymc traces from a db instance to a new db.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy_traces(db1, dbname, dbclass, traceclass, **kwargs): | |
"""Copy traces from a db to a new db. | |
""" | |
db = dbclass(dbname=dbname, dbmode='w', **kwargs) | |
db._initialize({}, 1) | |
db.trace_names = db1.trace_names | |
db.chains = 1 | |
# Create the Traces. | |
for name, trace in db1._traces.iteritems(): | |
db._traces[name] = traceclass(name=name, value={0:trace[:]}, db=db) | |
setattr(db, name, db._traces[name]) | |
# Load the state. | |
db._state_ = db1.getstate() | |
db._finalize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment