Skip to content

Commit

Permalink
Fixing failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelgloeckler committed Jul 26, 2024
1 parent e5f7212 commit b33e1c2
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sbi/inference/posteriors/base_posterior.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ def potential(
theta.to(self._device), track_gradients=track_gradients
)

def _x_else_default_x(self, x: Optional[Array]) -> Tensor:
if x is not None:
# New x, reset posterior sampler.
self._posterior_sampler = None
return process_x(
x, x_event_shape=None, allow_iid_x=self.potential_fn.allow_iid_x
)
elif self.default_x is None:
raise ValueError(
"Context `x` needed when a default has not been set."
"If you'd like to have a default, use the `.set_default_x()` method."
)
else:
return self.default_x

def _calculate_map(
self,
num_iter: int = 1_000,
Expand Down
Loading

0 comments on commit b33e1c2

Please sign in to comment.