make "pairs" with non-finite same as arrayToQPath
This commit is contained in:
parent
5d55808a90
commit
1e2596c9be
@ -556,10 +556,14 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
if isinstance(connect, np.ndarray):
|
if isinstance(connect, np.ndarray):
|
||||||
connect_array, connect = connect, 'array'
|
connect_array, connect = connect, 'array'
|
||||||
|
|
||||||
if connect == 'all' and not self.opts['skipFiniteCheck']:
|
all_finite = True
|
||||||
# remove non-finite points, if any
|
if (not self.opts['skipFiniteCheck']) or connect == 'finite':
|
||||||
mask = np.isfinite(x) & np.isfinite(y)
|
mask = np.isfinite(x) & np.isfinite(y)
|
||||||
if not np.all(mask):
|
all_finite = np.all(mask)
|
||||||
|
|
||||||
|
if connect == 'all':
|
||||||
|
if not all_finite:
|
||||||
|
# remove non-finite points, if any
|
||||||
x = x[mask]
|
x = x[mask]
|
||||||
y = y[mask]
|
y = y[mask]
|
||||||
npts = len(x)
|
npts = len(x)
|
||||||
@ -567,15 +571,14 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif connect == 'finite':
|
elif connect == 'finite':
|
||||||
mask = np.isfinite(x) & np.isfinite(y)
|
if not all_finite:
|
||||||
# each non-finite point affects the segment before and after
|
# each non-finite point affects the segment before and after
|
||||||
connect_array = mask[:-1] & mask[1:]
|
connect_array = mask[:-1] & mask[1:]
|
||||||
|
|
||||||
elif connect == 'array' and not self.opts['skipFiniteCheck']:
|
elif connect in ['pairs', 'array']:
|
||||||
# replicate the behavior of arrayToQPath
|
if not all_finite:
|
||||||
isfinite = np.isfinite(x) & np.isfinite(y)
|
# replicate the behavior of arrayToQPath
|
||||||
if not np.all(isfinite):
|
backfill_idx = fn._compute_backfill_indices(mask)
|
||||||
backfill_idx = fn._compute_backfill_indices(isfinite)
|
|
||||||
x = x[backfill_idx]
|
x = x[backfill_idx]
|
||||||
y = y[backfill_idx]
|
y = y[backfill_idx]
|
||||||
|
|
||||||
@ -592,17 +595,10 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
|
|
||||||
elif connect in ['pairs']:
|
elif connect in ['pairs']:
|
||||||
npairs = npts // 2
|
npairs = npts // 2
|
||||||
x = x[:npairs * 2] # ensure even number of points
|
|
||||||
y = y[:npairs * 2]
|
|
||||||
memory = segments.array(npairs).reshape((-1, 2))
|
memory = segments.array(npairs).reshape((-1, 2))
|
||||||
memory[:, 0] = x
|
memory[:, 0] = x[:npairs * 2]
|
||||||
memory[:, 1] = y
|
memory[:, 1] = y[:npairs * 2]
|
||||||
segs = segments.instances(npairs)
|
segs = segments.instances(npairs)
|
||||||
if not self.opts['skipFiniteCheck']:
|
|
||||||
mask = np.isfinite(x) & np.isfinite(y)
|
|
||||||
mask = mask[0::2] & mask[1::2]
|
|
||||||
if not np.all(mask):
|
|
||||||
segs = list(itertools.compress(segs, mask))
|
|
||||||
painter.drawLines(segs)
|
painter.drawLines(segs)
|
||||||
|
|
||||||
@debug.warnOnException ## raising an exception here causes crash
|
@debug.warnOnException ## raising an exception here causes crash
|
||||||
|
Loading…
Reference in New Issue
Block a user