Skip to content

Commit

Permalink
Fix external C++ doc
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Aug 22, 2022
1 parent 8ec7d0a commit 03952e1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
4 changes: 3 additions & 1 deletion cmdstanpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ def compile(
x for x in lines if x.startswith('Semantic error')
]
exceptions = [
x for x in lines if x.startswith('Uncaught exception')
x
for x in lines
if 'Uncaught exception' in x or 'fatal error' in x
]
if (
len(syntax_errors) > 0
Expand Down
2 changes: 1 addition & 1 deletion cmdstanpy/stanfit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,5 @@ def from_csv(
return None
except (IOError, OSError, PermissionError) as e:
raise ValueError(
'An error occured processing the CSV files:\n\t{}'.format(str(e))
'An error occurred processing the CSV files:\n\t{}'.format(str(e))
) from e
2 changes: 1 addition & 1 deletion docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def emit(self, record):
"CmdStanMCGQ": "~cmdstanpy.CmdStanMCGQ",
}

nbsphinx_allow_errors = True
nbsphinx_allow_errors = False

# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
Expand Down
24 changes: 17 additions & 7 deletions docsrc/users-guide/examples/Using External C++.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {"nbsphinx": "hidden"},
"metadata": {
"nbsphinx": "hidden"
},
"outputs": [],
"source": [
"import os\n",
Expand Down Expand Up @@ -50,7 +52,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"raises-exception"
]
},
"outputs": [],
"source": [
"model_external.compile()"
Expand All @@ -66,7 +72,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"raises-exception"
]
},
"outputs": [],
"source": [
"model_external.compile(stanc_options={'allow-undefined':True})"
Expand Down Expand Up @@ -135,7 +145,8 @@
"hash": "8765ce46b013071999fc1966b52035a7309a0da7551e066cc0f0fa23e83d4f60"
},
"kernelspec": {
"display_name": "Python 3.9.5 64-bit ('stan': conda)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -149,9 +160,8 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
8 changes: 6 additions & 2 deletions docsrc/users-guide/examples/Variational Inference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"raises-exception"
]
},
"outputs": [],
"source": [
"model_fail = CmdStanModel(stan_file='eta_should_fail.stan')\n",
Expand Down Expand Up @@ -172,7 +176,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.5"
}
},
"nbformat": 4,
Expand Down
18 changes: 18 additions & 0 deletions docsrc/users-guide/examples/bernoulli_external.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
functions {
real make_odds(real theta);
}
data {
int<lower=0> N;
array[N] int<lower=0, upper=1> y;
}
parameters {
real<lower=0, upper=1> theta;
}
model {
theta ~ beta(1, 1); // uniform prior on interval 0, 1
y ~ bernoulli(theta);
}
generated quantities {
real odds;
odds = make_odds(theta);
}

0 comments on commit 03952e1

Please sign in to comment.