Skip to content

Commit 5ed096e

Browse files
authored
Merge pull request #534 from grburgess/fix-0-flag-bug
fix numbering of compiler options
2 parents 13661f5 + 564ccb6 commit 5ed096e

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

cmdstanpy/compiler_opts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
STANC_OPTS = [
1313
'O',
14+
'O0',
1415
'O1',
15-
'O2',
1616
'Oexperimental',
1717
'allow-undefined',
1818
'use-opencl',

test/test_model.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,26 @@ def test_model_bad(self):
127127
CmdStanModel(stan_file=BERN_STAN, exe_file=BERN_EXE)
128128

129129
def test_stanc_options(self):
130-
opts = {
131-
'O': True,
132-
'allow-undefined': True,
133-
'use-opencl': True,
134-
'name': 'foo',
135-
}
136-
model = CmdStanModel(
137-
stan_file=BERN_STAN, compile=False, stanc_options=opts
138-
)
139-
stanc_opts = model.stanc_options
140-
self.assertTrue(stanc_opts['O'])
141-
self.assertTrue(stanc_opts['allow-undefined'])
142-
self.assertTrue(stanc_opts['use-opencl'])
143-
self.assertTrue(stanc_opts['name'] == 'foo')
144130

145-
cpp_opts = model.cpp_options
146-
self.assertEqual(cpp_opts['STAN_OPENCL'], 'TRUE')
131+
allowed_optims = ("", "0", "1", "experimental")
132+
for optim in allowed_optims:
133+
opts = {
134+
f'O{optim}': True,
135+
'allow-undefined': True,
136+
'use-opencl': True,
137+
'name': 'foo',
138+
}
139+
model = CmdStanModel(
140+
stan_file=BERN_STAN, compile=False, stanc_options=opts
141+
)
142+
stanc_opts = model.stanc_options
143+
self.assertTrue(stanc_opts[f'O{optim}'])
144+
self.assertTrue(stanc_opts['allow-undefined'])
145+
self.assertTrue(stanc_opts['use-opencl'])
146+
self.assertTrue(stanc_opts['name'] == 'foo')
147+
148+
cpp_opts = model.cpp_options
149+
self.assertEqual(cpp_opts['STAN_OPENCL'], 'TRUE')
147150

148151
with self.assertRaises(ValueError):
149152
bad_opts = {'X': True}

0 commit comments

Comments
 (0)