Commit 0f084758 authored by Gordian Edenhofer's avatar Gordian Edenhofer
Browse files

SandwichOperator: Set `draw_sample_with_dtype`

parent 27122307
Pipeline #110589 passed with stages
in 15 minutes and 1 second
......@@ -98,6 +98,22 @@ class SandwichOperator(EndomorphicOperator):
return self._bun.adjoint_times(
self._cheese.draw_sample(from_inverse))
def draw_sample_with_dtype(self, dtype, from_inverse=False):
# Inverse samples from general sandwiches are not possible
if from_inverse:
if self._bun.capability & self._bun.INVERSE_TIMES:
try:
s = self._cheese.draw_sample_with_dtype(dtype, from_inverse)
return self._bun.inverse_times(s)
except NotImplementedError:
pass
raise NotImplementedError(
"cannot draw from inverse of this operator")
# Samples from general sandwiches
return self._bun.adjoint_times(
self._cheese.draw_sample_with_dtype(dtype, from_inverse))
def get_sqrt(self):
if self._cheese is None:
return self._bun
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment