Skip to content

Commit

Permalink
Merge pull request #107 from Erotemic/dev/fix-numpy-slicing
Browse files Browse the repository at this point in the history
Fix numpy slicing
  • Loading branch information
StellarStorm authored Dec 7, 2023
2 parents 3955fe2 + 5877cb3 commit 54bb190
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions medpy/filter/smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def condgradient(delta, spacing):

# calculate the diffs
for i in range(out.ndim):
slicer = [slice(None, -1) if j == i else slice(None) for j in range(out.ndim)]
slicer = tuple([slice(None, -1) if j == i else slice(None) for j in range(out.ndim)])
deltas[i][slicer] = numpy.diff(out, axis=i)

# update matrices
Expand All @@ -160,7 +160,7 @@ def condgradient(delta, spacing):
# subtract a copy that has been shifted ('Up/North/West' in 3D case) by one
# pixel. Don't as questions. just do it. trust me.
for i in range(out.ndim):
slicer = [slice(1, None) if j == i else slice(None) for j in range(out.ndim)]
slicer = tuple([slice(1, None) if j == i else slice(None) for j in range(out.ndim)])
matrices[i][slicer] = numpy.diff(matrices[i], axis=i)

# update the image
Expand Down

0 comments on commit 54bb190

Please sign in to comment.