Do not crash on infs/nans in values, just discard plot
This commit is contained in:
@@ -60,8 +60,8 @@ class FitDamageStatsGraph(FitGraph):
|
||||
XDef(handle='tgtSigRad', unit='m', label='Target signature radius', mainInput=('tgtSigRad', '%')),
|
||||
XDef(handle='tgtSigRad', unit='%', label='Target signature radius', mainInput=('tgtSigRad', '%'))]
|
||||
inputs = [
|
||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=None, defaultRange=(0, 80), secondaryTooltip='When set, uses attacker\'s exact damage stats at a given time\nWhen not set, uses attacker\'s damage stats as shown in stats panel of main window'),
|
||||
Input(handle='distance', unit='km', label='Distance', iconID=1391, defaultValue=None, defaultRange=(0, 100), mainTooltip='Distance between the attacker and the target, as seen in overview (surface-to-surface)', secondaryTooltip='Distance between the attacker and the target, as seen in overview (surface-to-surface)\nWhen set, places the target that far away from the attacker\nWhen not set, attacker\'s weapons always hit the target'),
|
||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=None, defaultRange=(0, 80), secondaryTooltip='When set, uses attacker\'s exact damage stats at a given time\nWhen not set, uses attacker\'s damage stats as shown in stats panel of main window'),
|
||||
Input(handle='tgtSpeed', unit='%', label='Target speed', iconID=1389, defaultValue=100, defaultRange=(0, 100)),
|
||||
Input(handle='tgtSigRad', unit='%', label='Target signature', iconID=1390, defaultValue=100, defaultRange=(100, 200), conditions=[
|
||||
(('tgtSigRad', 'm'), None),
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user