From 103fb0bae0cf9f6cb8e9fe3a99532c7befc270b3 Mon Sep 17 00:00:00 2001
From: Reimar Leike <reimar@leike.name>
Date: Fri, 15 Jun 2018 16:45:44 +0200
Subject: [PATCH] added sample-functionality to sandwich operator when it is
 analytically possible

---
 nifty4/operators/sandwich_operator.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nifty4/operators/sandwich_operator.py b/nifty4/operators/sandwich_operator.py
index 6dd77647d..55d96d29f 100644
--- a/nifty4/operators/sandwich_operator.py
+++ b/nifty4/operators/sandwich_operator.py
@@ -76,6 +76,12 @@ class SandwichOperator(EndomorphicOperator):
     def draw_sample(self, from_inverse=False, dtype=np.float64):
         # Inverse samples from general sandwiches is not possible
         if from_inverse:
+            if self._bun.capabilities & self._bun.INVERSE_TIMES:
+                try:
+                    s = self._cheese.draw_sample(from_inverse, dtype)
+                    return self._bun.inverse_times(s)
+                except:
+                    pass
             raise NotImplementedError(
                 "cannot draw from inverse of this operator")
 
-- 
GitLab