Skip to content

Commit

Permalink
Merge pull request #3708 from silx-kit/fix-slice-profile
Browse files Browse the repository at this point in the history
Fix slice profile
  • Loading branch information
t20100 authored Oct 27, 2022
2 parents 547154b + da4f98b commit 0d6324e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/silx/gui/plot/tools/profile/rois.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,19 @@ def argnearest(array, value):

if major_axis:
# slice in the middle of the scatter
start = max_grid_second // 2 * max_grid_first
vslice = axis[start:start + max_grid_second]
actual_size_grid_second = len(axis) // max_grid_first
start = actual_size_grid_second // 2 * max_grid_first
vslice = axis[start:start + max_grid_first]
if len(vslice) == 0:
return None
index = argnearest(vslice, position)
slicing = slice(index, None, max_grid_first)
else:
# slice in the middle of the scatter
vslice = axis[max_grid_second // 2::max_grid_second]
actual_size_grid_second = len(axis) // max_grid_first
vslice = axis[actual_size_grid_second // 2::max_grid_second]
if len(vslice) == 0:
return None
index = argnearest(vslice, position)
start = index * max_grid_second
slicing = slice(start, start + max_grid_second)
Expand Down

0 comments on commit 0d6324e

Please sign in to comment.