Error for unrecognized options in StanBackend.set_options

This commit is contained in:
Ben Letham 2021-03-03 18:04:15 -08:00
parent 4e99ac686e
commit 74b21f7cd9

View file

@ -28,8 +28,12 @@ class IStanBackend(ABC):
Specify model options as kwargs.
* newton_fallback [bool]: whether to fallback to Newton if L-BFGS fails
"""
if 'newton_fallback' in kwargs:
self.newton_fallback = kwargs['newton_fallback']
for k, v in kwargs.items():
if k == 'newton_fallback':
self.newton_fallback = v
else:
raise ValueError(f'Unknown option {k}')
@staticmethod
@abstractmethod
@ -291,4 +295,4 @@ class StanBackendEnum(Enum):
try:
return StanBackendEnum[name].value
except KeyError as e:
raise ValueError("Unknown stan backend: {}".format(name)) from e
raise ValueError("Unknown stan backend: {}".format(name)) from e