Do not crash on infs/nans in values, just discard plot

This commit is contained in:
DarkPhoenix
2019-08-19 12:48:26 +03:00
parent 01bda70fef
commit 9494885f45
2 changed files with 12 additions and 1 deletions

View File

@@ -19,6 +19,7 @@
import itertools
import math
import os
import traceback
from bisect import bisect
@@ -149,6 +150,9 @@ class GraphCanvasPanel(wx.Panel):
ySpec=chosenY,
src=source,
tgt=target)
if not self.__checkNumbers(xs, ys):
pyfalog.warning('Failed to plot "{}" vs "{}" due to inf or NaN in values'.format(source.name, '' if target is None else target.name))
continue
plotData[(source, target)] = (xs, ys)
allXs.update(xs)
allYs.update(ys)
@@ -299,6 +303,13 @@ class GraphCanvasPanel(wx.Panel):
y = y1 + pos * (y2 - y1)
return y
@staticmethod
def __checkNumbers(xs, ys):
for number in itertools.chain(xs, ys):
if math.isnan(number) or math.isinf(number):
return False
return True
# Matplotlib event handlers
def OnMplCanvasClick(self, event):
if event.button == 1: