Skip to content

Commit a90458f

Browse files
author
Bert Vandenbroucke
committed
Filter out NaN values when computing lines to prevent weird unyt.matplotlib_support crashes for lines that only have NaN x values.
1 parent 8d45ce6 commit a90458f

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)