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

Commit 4f93670

Browse files
authored
Merge pull request #294 from stan-dev/feature/services-exception
TST: update test checking gradient error exception message propogation
2 parents f6f6b7b + 7270c87 commit 4f93670

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

pystan/tests/test_rstan_stanfit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def test_init_zero_exception_inf_grad(self):
2020
}
2121
"""
2222
sm = StanModel(model_code=code)
23-
assertRaisesRegex = self.assertRaisesRegexp if PY2 else self.assertRaisesRegex
24-
with assertRaisesRegex(RuntimeError, ''):
23+
with self.assertRaises(RuntimeError):
2524
sm.sampling(init='0', iter=1, chains=1)
2625

2726
def test_grad_log(self):

pystan/tests/test_user_inits.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,9 @@ def test_user_init_unspecified(self):
7272
}
7373
"""
7474
data = self.data
75-
# NOTE: we are only specifying 'mu' and not 'sigma'
76-
# This behavior works now.
77-
try:
78-
pystan.stan(model_code=model_code, iter=10, chains=1, seed=2,
79-
data=data, init=[dict(mu=4)], warmup=0)
80-
except RuntimeError:
81-
self.fail("pystan.stan() raised RuntimeError on partial init")
75+
# NOTE: we are only specifying 'mu' and not 'sigma' (partial inits)
76+
fit = pystan.stan(model_code=model_code, iter=10, chains=1, seed=2, data=data, init=[dict(mu=4)], warmup=0)
77+
self.assertIsNotNone(fit)
8278

8379

8480
class TestUserInitsMatrix(unittest.TestCase):

0 commit comments

Comments
 (0)