Skip to content

Commit 390ad7b

Browse files
committed
co-ordinate notebooks, writeup
1 parent b6f36be commit 390ad7b

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

knitr/cloud-compute-2020/CmdStanR_Example_Notebook.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
},
104104
"source": [
105105
"# Install CmdStan binaries\n",
106-
"if (!file.exists(\"cmdstan-2-22-1.tgz\")) {\n",
106+
"if (!file.exists(\"cmdstan-2.23.0.tgz\")) {\n",
107107
" system(\"wget https://github.com/stan-dev/cmdstan/releases/download/v2.23.0/colab-cmdstan-2.23.0.tar.gz\", intern=T)\n",
108108
" system(\"tar zxf colab-cmdstan-2.23.0.tar.gz\", intern=T)\n",
109109
"}\n",

knitr/cloud-compute-2020/jupyter_colab_notebooks_2020.Rmd

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,16 @@ if(!require(cmdstanr)){
284284
}
285285
```
286286
The following cells download the precompiled CmdStan binaries
287-
and register the path to the CmdStan installation:
287+
and registers the path to the CmdStan installation:
288288
```
289289
# Install CmdStan binaries
290-
if (!file.exists("cmdstan-2-22-1.tgz")) {
291-
system("wget https://storage.googleapis.com/cmdstan-2-22-tgz/cmdstan-2-22-1.tgz", intern=T)
292-
system("tar zxf cmdstan-2-22-1.tgz", intern=T)
290+
if (!file.exists("cmdstan-2.23.0.tgz")) {
291+
system("wget https://github.com/stan-dev/cmdstan/releases/download/v2.23.0/colab-cmdstan-2.23.0.tar.gz", intern=T)
292+
system("tar zxf colab-cmdstan-2.23.0.tar.gz", intern=T)
293293
}
294-
list.files("cmdstan-2.22.1")
295294
296295
# Set cmdstan_path to CmdStan installation
297-
set_cmdstan_path("cmdstan-2.22.1")
296+
set_cmdstan_path("cmdstan-2.23.0")
298297
```
299298

300299
#### Spinning up a CmdStanPy Notebook
@@ -308,28 +307,20 @@ CmdStanPy is a pure-Python package which can be installed from PyPI:
308307
```
309308
We can use Python to download and unpack the precompiled CmdStan binaries:
310309
```
311-
# Download, unpack CmdStan binaries
312-
import os
313-
import urllib.request
314-
import shutil
315-
tgz_file = 'cmdstan-2-22-1.tgz'
316-
tgz_url = 'https://storage.googleapis.com/cmdstan-2-22-tgz/cmdstan-2-22-1.tgz'
317-
310+
# Install pre-built CmdStan binary
311+
# (faster than compiling from source via install_cmdstan() function)
312+
tgz_file = 'colab-cmdstan-2.23.0.tar.gz'
313+
tgz_url = 'https://github.com/stan-dev/cmdstan/releases/download/v2.23.0/colab-cmdstan-2.23.0.tar.gz'
318314
if not os.path.exists(tgz_file):
319-
try:
320315
urllib.request.urlretrieve(tgz_url, tgz_file)
321316
shutil.unpack_archive(tgz_file)
322-
except Exception:
323-
raise KeyboardInterrupt
324317
```
325318
The following cells check the CmdStan installation and register its location:
326319
```
327320
# Specify CmdStan location via environment variable
328-
import os
329-
os.environ['CMDSTAN'] = './cmdstan-2.22.1'
330-
321+
os.environ['CMDSTAN'] = './cmdstan-2.23.0'
331322
# Check CmdStan path
332-
from cmdstanpy import cmdstan_path
323+
from cmdstanpy import CmdStanModel, cmdstan_path
333324
cmdstan_path()
334325
```
335326

@@ -457,12 +448,6 @@ An extremely interesting Stan notebook would expand the above to the full Bayesi
457448

458449

459450

460-
461-
462-
463-
464-
465-
466451

467452

468453

0 commit comments

Comments
 (0)