@@ -140,7 +140,8 @@ def to_botorch(
140
140
141
141
Raises:
142
142
RuntimeError: When the constraint is an interpoint constraint but
143
- ``batch_size`` is ``None``.
143
+ ``batch_size`` is ``None`` or when providing a value for ``batch_size``
144
+ while the constraint is not an interpoint constraint.
144
145
"""
145
146
import torch
146
147
@@ -151,6 +152,17 @@ def to_botorch(
151
152
# See https://botorch.readthedocs.io/en/latest/optim.html, in particular the
152
153
# docstring of ``optimize_acqf`` for details.
153
154
155
+ if batch_size is None and self .is_interpoint :
156
+ raise RuntimeError (
157
+ "No ``batch_size`` set but using interpoint constraints."
158
+ "This should not happen and means that there is a bug in the code."
159
+ )
160
+ if batch_size is not None and not self .is_interpoint :
161
+ raise RuntimeError (
162
+ "A ``batch_size`` was set but the constraint is not interpoint."
163
+ "This should not happen and means that there is a bug in the code."
164
+ )
165
+
154
166
param_names = [p .name for p in parameters ]
155
167
coefficients : list [float ]
156
168
torch_indices : Tensor
@@ -162,11 +174,6 @@ def to_botorch(
162
174
]
163
175
coefficients = self .coefficients
164
176
torch_indices = torch .tensor (param_indices )
165
- elif batch_size is None :
166
- raise RuntimeError (
167
- "No ``batch_size`` set but using interpoint constraints."
168
- "This should not happen and means that there is a bug in the code."
169
- )
170
177
else :
171
178
param_index_dict = {
172
179
name : param_names .index (name ) for name in self .parameters
0 commit comments