Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit de06fe6

Browse files
committed
update stan_cache to StanModel_cache
1 parent 64be205 commit de06fe6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/avoiding_recompilation.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ available.
116116
import pickle
117117
from hashlib import md5
118118
119-
def stan_cache(model_code, model_name=None, **kwargs):
119+
def StanModel_cache(model_code, model_name=None, **kwargs):
120120
"""Use just as you would `stan`"""
121121
code_hash = md5(model_code.encode('ascii')).hexdigest()
122122
if model_name is None:
@@ -131,14 +131,16 @@ available.
131131
pickle.dump(sm, f)
132132
else:
133133
print("Using cached StanModel")
134-
return sm.sampling(**kwargs)
134+
return sm
135135
136136
# with same model_code as before
137137
data = dict(N=10, y=[0, 1, 0, 0, 0, 0, 0, 0, 0, 1])
138-
fit = stan_cache(model_code=model_code, data=data)
138+
sm = StanModel_cache(model_code=model_code)
139+
fit = sm.sampling(data=data)
139140
print(fit)
140141
141142
new_data = dict(N=6, y=[0, 0, 0, 0, 0, 1])
142143
# the cached copy of the model will be used
143-
fit2 = stan_cache(model_code=model_code, data=new_data)
144+
sm = StanModel_cache(model_code=model_code)
145+
fit2 = sm.sampling(data=new_data)
144146
print(fit2)

0 commit comments

Comments
 (0)