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

Commit 224fd2d

Browse files
authored
Merge pull request #336 from stan-dev/randommm-patch-1
Remove pystan.stan from README.rst and other places in documentation
2 parents 7470ce2 + de06fe6 commit 224fd2d

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ Example
100100
'y': [28, 8, -3, 7, -1, 1, 18, 12],
101101
'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}
102102

103-
fit = pystan.stan(model_code=schools_code, data=schools_dat,
104-
iter=1000, chains=4)
103+
sm = pystan.StanModel(model_code=schools_code)
104+
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
105105

106106
print(fit)
107107

@@ -111,7 +111,7 @@ Example
111111
# if matplotlib is installed (optional, not required), a visual summary and
112112
# traceplot are available
113113
fit.plot()
114-
plt.show()
114+
plt.show()
115115

116116
.. |pypi| image:: https://badge.fury.io/py/pystan.png
117117
:target: https://badge.fury.io/py/pystan

doc/avoiding_recompilation.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ whenever possible. If the same model is going to be used repeatedly, we would
1111
like to compile it just once. The following demonstrates how to reuse a model in
1212
different scripts and between interactive Python sessions.
1313

14-
**Within sessions** you can avoid recompiling a model in two ways. The simplest
14+
**Within sessions** you can avoid recompiling a model in two ways. The first
1515
method is to reuse a fit object in the call to ``stan``. For example,
1616

1717
.. code-block:: python
@@ -45,8 +45,10 @@ method is to reuse a fit object in the call to ``stan``. For example,
4545
fit2 = stan(fit=fit, data=new_data)
4646
print(fit2)
4747
48-
Alternatively, we can compile the model once using the ``StanModel`` class and
49-
then sample from the model using the ``sampling`` method.
48+
However, calling ``pystan.stan`` is deprecated and will soon be removed from
49+
PyStan. The recommended method is to compile the model once using the
50+
``StanModel`` class and then sample from the model using the ``sampling``
51+
method.
5052

5153
.. code-block:: python
5254
@@ -114,7 +116,7 @@ available.
114116
import pickle
115117
from hashlib import md5
116118
117-
def stan_cache(model_code, model_name=None, **kwargs):
119+
def StanModel_cache(model_code, model_name=None, **kwargs):
118120
"""Use just as you would `stan`"""
119121
code_hash = md5(model_code.encode('ascii')).hexdigest()
120122
if model_name is None:
@@ -129,14 +131,16 @@ available.
129131
pickle.dump(sm, f)
130132
else:
131133
print("Using cached StanModel")
132-
return sm.sampling(**kwargs)
134+
return sm
133135
134136
# with same model_code as before
135137
data = dict(N=10, y=[0, 1, 0, 0, 0, 0, 0, 0, 0, 1])
136-
fit = stan_cache(model_code=model_code, data=data)
138+
sm = StanModel_cache(model_code=model_code)
139+
fit = sm.sampling(data=data)
137140
print(fit)
138141
139142
new_data = dict(N=6, y=[0, 0, 0, 0, 0, 1])
140143
# the cached copy of the model will be used
141-
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)
142146
print(fit2)

doc/getting_started.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Getting started
77
=================
88

9-
PyStan is the `Python <http://python.org>`_ interface for `Stan <http://mc-stan.org/>`_.
9+
PyStan is the `Python <http://python.org>`_ interface for
10+
`Stan <http://mc-stan.org/>`_.
1011

1112
Prerequisites
1213
=============
@@ -108,8 +109,8 @@ which studied coaching effects from eight schools.
108109
'y': [28, 8, -3, 7, -1, 1, 18, 12],
109110
'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}
110111
111-
fit = pystan.stan(model_code=schools_code, data=schools_dat,
112-
iter=1000, chains=4)
112+
sm = pystan.StanModel(model_code=schools_code)
113+
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
113114
114115
In this model, we let ``theta`` be transformed parameters of ``mu`` and ``eta``
115116
instead of directly declaring theta as parameters. By parameterizing this way,
@@ -121,17 +122,16 @@ our working directory and use the following call to ``stan`` instead:
121122

122123
.. code-block:: python
123124
124-
fit1 = pystan.stan(file='8schools.stan', data=schools_dat, iter=1000, chains=4)
125+
sm = pystan.StanModel(file='8schools.stan')
126+
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
125127
126-
Once a model is fitted, we can use the fitted result as an input to the model
127-
with other data or settings. This saves us time compiling the C++ code for the
128-
model. By specifying the parameter ``fit`` for the ``stan`` function, we can fit
129-
the model again. For example, if we want to sample more iterations, we proceed
130-
as follows:
128+
Once a model is compiled, we can use the StanModel object multiple times.
129+
This saves us time compiling the C++ code for the model. For example, if we
130+
want to sample more iterations, we proceed as follows:
131131

132132
.. code-block:: python
133133
134-
fit2 = pystan.stan(fit=fit1, data=schools_dat, iter=10000, chains=4)
134+
fit2 = sm.sampling(data=schools_dat, iter=10000, chains=4)
135135
136136
The object ``fit``, returned from function ``stan`` stores samples from the
137137
posterior distribution. The ``fit`` object has a number of methods, including
@@ -154,7 +154,8 @@ parameters of interest, or just an array.
154154
155155
print(fit)
156156
157-
If `matplotlib <http://matplotlib.org/>`_ and `scipy <http://http://www.scipy.org/>`_ are installed, a visual summary may
157+
If `matplotlib <http://matplotlib.org/>`_ and
158+
`scipy <http://http://www.scipy.org/>`_ are installed, a visual summary may
158159
also be displayed using the ``plot()`` method.
159160

160161
.. code-block:: python

doc/installation_beginner.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ package manager (that also plays nicely with ``pip``) called ``conda``,
3939
and comes with many of the data analytics packages and dependencies
4040
pre-installed.
4141

42-
Don't worry about Anaconda ruining your current Python installation, can
42+
Don't worry about Anaconda ruining your current Python installation, it
4343
can be easily uninstalled (described below).
4444

4545
Anaconda is not a requirement

0 commit comments

Comments
 (0)