Skip to content

Commit 9dc5111

Browse files
committed
Clarify resolve stanc/cpp options functions
1 parent 9b1759e commit 9dc5111

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmdstanpy/model.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,21 @@ def code(self) -> str | None:
264264
def _resolve_cpp_options(
265265
cpp_options: dict[str, Any] | None, multithreading: bool
266266
) -> dict[str, Any]:
267-
out = {}
268-
if multithreading:
267+
out = cpp_options or {}
268+
out = out.copy()
269+
if multithreading and "STAN_THREADS" not in out:
269270
out["STAN_THREADS"] = "TRUE"
270-
return out | cpp_options if cpp_options else out
271+
return out
271272

272273
@staticmethod
273274
def _resolve_stanc_options(
274275
stanc_options: dict[str, Any] | None, stanc_optimizations: bool
275276
) -> dict[str, Any]:
276-
out = {}
277-
if stanc_optimizations:
277+
out = stanc_options or {}
278+
out = out.copy()
279+
if stanc_optimizations and "O" not in out:
278280
out["O"] = 1
279-
return out | stanc_options if stanc_options else out
281+
return out
280282

281283
def optimize(
282284
self,

0 commit comments

Comments
 (0)