Skip to content

Commit

Permalink
Try again to fix the flags.writeable problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-T-McCann committed Dec 18, 2023
1 parent 88f04fe commit 707b851
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scico/linop/xray/astra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 707b851

Please sign in to comment.