Skip to content

Commit 58781ca

Browse files
committed
Fix bug in segment line cross section computation for masked images
1 parent c7b0cdc commit 58781ca

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog #
22

3+
## Version 2.5.2 ##
4+
5+
🛠️ Bug fixes:
6+
7+
* Fixed segment line cross section computation for masked images:
8+
* Avoided warning message when encountering masked values in the image data
9+
* Replacing masked values by NaNs when computing the segment line cross section (as before, but explicitely, to avoid the warning message)
10+
311
## Version 2.5.1 ##
412

513
ℹ️ Release V2.5.0 was a fugitive release that was replaced by V2.5.1 due to packaging issues.

plotpy/panels/csection/csitem.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ def compute_line_section(
477477
row0, row1 = min(row0, row1), max(row0, row1)
478478
col0, col1 = min(col0, col1), max(col0, col1)
479479
# Extract the line
480-
line = np.zeros((2, max(abs(row1 - row0), abs(col1 - col0)) + 1), dtype=np.float64)
481-
line[0, :] = np.linspace(row0, row1, line.shape[1])
482-
line[1, :] = np.linspace(col0, col1, line.shape[1])
480+
line = np.zeros((2, max(abs(row1 - row0), abs(col1 - col0)) + 1), dtype=int)
481+
line[0, :] = np.linspace(row0, row1, line.shape[1]).astype(int)
482+
line[1, :] = np.linspace(col0, col1, line.shape[1]).astype(int)
483483
# Interpolate the line
484-
y = np.array([data[int(r), int(c)] for r, c in line.T])
484+
y = np.ma.array(data[line[0], line[1]]).filled(np.nan)
485485
x = np.arange(y.size)
486486
return x, y
487487

0 commit comments

Comments
 (0)