Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pints/interfaces/stan/_stan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import re
import warnings

import httpstan
import numpy as np

import httpstan
import stan

import pints
Expand All @@ -20,9 +21,9 @@ class StanLogPDF(pints.LogPDF):
A :class:`pints.LogPDF` based on Stan code and data, which can be used in
sampling and optimisation.

This class interfaces with Stan ([1]_) using PyStan ([2]_) and httpspan
([3]_), which compiles the Stan model code. This can take some time
(typically minutes).
This class interfaces with Stan ([1]_) using ``stan`` ([2]_) and
``httpspan`` ([3]_), which compiles the Stan model code. This can take some
time (typically minutes).

Note that the interface assumes that the parameters are on the
unconstrained scale (according to Stan's "constraint transforms" [1]_).
Expand All @@ -32,7 +33,7 @@ class StanLogPDF(pints.LogPDF):
back to the constrained space (in the example, using an ``exp`` transform)
to obtain appropriate samples.

Parameters are ordered as in the stan model. Vector and matrix parameters
Parameters are ordered as in the Stan model. Vector and matrix parameters
are "flattened" into a sequence by Stan, use :meth:`StanLogPDF.names()` to
see the result.

Expand Down
10 changes: 6 additions & 4 deletions pints/tests/test_interfaces_stan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
from shared import SubCapture


debug = False

no_stan_msg = None
try:
from pints.interfaces.stan import StanLogPDF
have_stan = True
except ImportError:
except ImportError as e:
have_stan = False

debug = False
no_stan_msg = f'PyStan not found: {e}'


@unittest.skipIf(not have_stan, 'PyStan not found')
@unittest.skipIf(not have_stan, no_stan_msg)
class TestStanLogPDF(unittest.TestCase):
""" Tests StanLogPDF. """

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def load_version():
],
'stan': [
'pystan>=3',
'setuptools<82',
]
},
python_requires='>=3.8',
Expand Down