From 707b851960c46cfa71056fb11b4e5225f4117556 Mon Sep 17 00:00:00 2001 From: Michael-T-McCann Date: Mon, 18 Dec 2023 09:40:45 -0700 Subject: [PATCH] Try again to fix the flags.writeable problem --- scico/linop/xray/astra.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scico/linop/xray/astra.py b/scico/linop/xray/astra.py index 8c97ac69f..0d6cff41c 100644 --- a/scico/linop/xray/astra.py +++ b/scico/linop/xray/astra.py @@ -185,7 +185,11 @@ def _proj(self, x: jax.Array) -> jax.Array: # apply the forward projector and generate a sinogram def f(x): - x.setflags(write=True) + if not x.flags.writeable: + try: + x.setflags(write=True) + except ValueError("cannot set WRITEABLE flag"): + x = x.copy() if self.num_dims == 2: proj_id, result = astra.create_sino(x, self.proj_id) astra.data2d.delete(proj_id) @@ -199,7 +203,11 @@ def f(x): def _bproj(self, y: jax.Array) -> jax.Array: # apply backprojector def f(y): - y.setflags(write=True) + if not y.flags.writeable: + try: + y.setflags(write=True) + except ValueError("cannot set WRITEABLE flag"): + y = y.copy() if self.num_dims == 2: proj_id, result = astra.create_backprojection(y, self.proj_id) astra.data2d.delete(proj_id)