Return a boolean array of valid points. Points are valid if they satisfy both the constraint and boundary conditions. Returns ------- np.ndarray
(self)
| 386 | |
| 387 | @property |
| 388 | def mask(self) -> NDArray[np.bool_]: |
| 389 | """Return a boolean array of valid points. |
| 390 | |
| 391 | Points are valid if they satisfy both the constraint and boundary conditions. |
| 392 | |
| 393 | Returns |
| 394 | ------- |
| 395 | np.ndarray |
| 396 | """ |
| 397 | mask = np.ones_like(self.target, dtype=bool) |
| 398 | |
| 399 | # mask points that don't satisfy the constraint |
| 400 | if self._constraint is not None: |
| 401 | mask &= self._constraint.allowed(self._constraint_values) |
| 402 | |
| 403 | # mask points that are outside the bounds |
| 404 | if self._bounds is not None: |
| 405 | within_bounds = np.all( |
| 406 | (self._bounds[:, 0] <= self._params) & (self._params <= self._bounds[:, 1]), axis=1 |
| 407 | ) |
| 408 | mask &= within_bounds |
| 409 | |
| 410 | return mask |
| 411 | |
| 412 | def _as_array(self, x: Any) -> NDArray[Float]: |
| 413 | try: |