Skip to content

Commit 8264d48

Browse files
authored
Merge pull request #88 from SWIFTSIM/nan-median-lines-bug
Filter out NaN values when computing lines
2 parents 8d45ce6 + a90458f commit 8264d48

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

velociraptor/autoplotter/lines.py

+9
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ def create_line(
243243
masked_x = x
244244
masked_y = y
245245

246+
# filter out NaN values to prevent crashes if all x values are NaN
247+
if masked_y is not None:
248+
mask = isnan(x) | isnan(y)
249+
masked_x = masked_x[~mask]
250+
masked_y = masked_y[~mask]
251+
else:
252+
mask = isnan(x)
253+
masked_x = masked_x[~mask]
254+
246255
if self.lower is not None:
247256
self.lower.convert_to_units(y.units)
248257
mask = masked_y > self.lower

0 commit comments

Comments
 (0)