Skip to content

Commit 5b80eb8

Browse files
authored
Merge pull request #496 from stan-dev/bugfix/force-compile
Bugfix/force compile
2 parents 0c8e855 + d938da2 commit 5b80eb8

13 files changed

Lines changed: 551 additions & 332 deletions

cmdstanpy/compiler_opts.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ def __repr__(self) -> str:
6767
self._stanc_options, self._cpp_options
6868
)
6969

70+
def __eq__(self, other: Any) -> bool:
71+
"""Overrides the default implementation"""
72+
if self.is_empty() and other is None: # equiv w/r/t compiler
73+
return True
74+
if not isinstance(other, CompilerOptions):
75+
return False
76+
return (
77+
self._stanc_options == other.stanc_options
78+
and self._cpp_options == other.cpp_options
79+
and self._user_header == other.user_header
80+
)
81+
82+
def is_empty(self) -> bool:
83+
"""True if no options specified."""
84+
return (
85+
self._stanc_options == {}
86+
and self._cpp_options == {}
87+
and self._user_header == ''
88+
)
89+
7090
@property
7191
def stanc_options(self) -> Dict[str, Union[bool, int, str]]:
7292
"""Stanc compiler options."""
@@ -77,6 +97,11 @@ def cpp_options(self) -> Dict[str, Union[bool, int]]:
7797
"""C++ compiler options."""
7898
return self._cpp_options
7999

100+
@property
101+
def user_header(self) -> str:
102+
"""user header."""
103+
return self._user_header
104+
80105
def validate(self) -> None:
81106
"""
82107
Check compiler args.

0 commit comments

Comments
 (0)