From 5ab77c8997f35d8da34a9a2d19ffcfe4b4a4d488 Mon Sep 17 00:00:00 2001 From: Michael Clerx Date: Fri, 6 Mar 2026 14:54:47 +0000 Subject: [PATCH] Fixed pystan testing issue. --- pints/interfaces/stan/_stan.py | 11 ++++++----- pints/tests/test_interfaces_stan.py | 10 ++++++---- setup.py | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pints/interfaces/stan/_stan.py b/pints/interfaces/stan/_stan.py index 7ae450cc3..78f32fee6 100644 --- a/pints/interfaces/stan/_stan.py +++ b/pints/interfaces/stan/_stan.py @@ -8,8 +8,9 @@ import re import warnings -import httpstan import numpy as np + +import httpstan import stan import pints @@ -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]_). @@ -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. diff --git a/pints/tests/test_interfaces_stan.py b/pints/tests/test_interfaces_stan.py index 474ea3e9e..05bef53c7 100755 --- a/pints/tests/test_interfaces_stan.py +++ b/pints/tests/test_interfaces_stan.py @@ -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. """ diff --git a/setup.py b/setup.py index a96837c7d..755c0796a 100644 --- a/setup.py +++ b/setup.py @@ -82,6 +82,7 @@ def load_version(): ], 'stan': [ 'pystan>=3', + 'setuptools<82', ] }, python_requires='>=3.8',