Skip to content

Instantly share code, notes, and snippets.

@bmmalone
Created March 12, 2018 09:18
Show Gist options
  • Save bmmalone/4574dc25e358ef0dca7006b6195642db to your computer and use it in GitHub Desktop.
Save bmmalone/4574dc25e358ef0dca7006b6195642db to your computer and use it in GitHub Desktop.
Pickle a stan model file (python3)
#! /usr/bin/env python3
import argparse
import pickle
from pystan import StanModel
def main():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="This script compiles a stan model and pickles it to disc")
parser.add_argument("stan", help="The stan model file")
parser.add_argument("out", help="The python3 pickle output file")
args = parser.parse_args()
sm = StanModel(file=args.stan)
with open(args.out, 'wb') as f:
pickle.dump(sm, f)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment