Commit 33216fd5 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'issue_236' into 'NIFTy_4'

improve handling of draw_sample()

See merge request ift/NIFTy!252
parents ca2ceecf bf617fae
Pipeline #28453 passed with stages
in 6 minutes and 9 seconds
......@@ -83,6 +83,6 @@ class InversionEnabler(EndomorphicOperator):
def draw_sample(self, from_inverse=False, dtype=np.float64):
try:
return self._op.draw_sample(from_inverse, dtype)
except:
except NotImplementedError:
samp = self._op.draw_sample(not from_inverse, dtype)
return self.inverse_times(samp) if from_inverse else self(samp)
......@@ -50,6 +50,7 @@ class SandwichOperator(EndomorphicOperator):
def draw_sample(self, from_inverse=False, dtype=np.float64):
if from_inverse:
raise ValueError("cannot draw from inverse of this operator")
raise NotImplementedError(
"cannot draw from inverse of this operator")
return self._bun.adjoint_times(
self._cheese.draw_sample(from_inverse, dtype))
......@@ -145,7 +145,8 @@ class SumOperator(LinearOperator):
def draw_sample(self, from_inverse=False, dtype=np.float64):
if from_inverse:
raise ValueError("cannot draw from inverse of this operator")
raise NotImplementedError(
"cannot draw from inverse of this operator")
res = self._ops[0].draw_sample(from_inverse, dtype)
for op in self._ops[1:]:
res += op.draw_sample(from_inverse, dtype)
......
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