Skip to content

Commit b05a583

Browse files
Bandaid fix #29: Complexity graph plot now raises exception if a negative value is encountered, may not be a real fix
1 parent b0154f7 commit b05a583

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

CanvasPanel.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from matplotlib import use
55
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
66
from matplotlib.backends.backend_wx import NavigationToolbar2Wx as NavigationToolbar
7-
from matplotlib.figure import Figure
7+
from matplotlib.pyplot import figure, yscale
88
from scipy.optimize import OptimizeWarning
99
from GraphDialogs import SymbolDialog
1010
from GraphDialogs import LegendDialog
@@ -25,7 +25,7 @@ def __init__(self, parent, data, error_txt, cvf, tree_menu, root, id):
2525
self.root = root
2626
self.parent = parent
2727
self.cvf = cvf
28-
self.figure = Figure()
28+
self.figure = figure()
2929
# defines the plot using subplot function
3030
self.axes = self.get_fig().add_subplot(111)
3131

@@ -616,7 +616,7 @@ def __init__(self, parent, x, xr, y, cvf, swb, tree):
616616
self.workbook = self.tree_menu.GetItemData(swb).get_wb()
617617
self.swb = swb
618618
self.cvf = cvf
619-
self.figure = Figure()
619+
self.figure = figure()
620620
# defines the plot
621621
self.axes = self.get_fig().add_subplot(111)
622622

@@ -1891,7 +1891,7 @@ class SclbyAreaPlot(wx.Panel):
18911891
def __init__(self, parent, x, y, data):
18921892
# gets the Panel properties
18931893
wx.Panel.__init__(self, parent, size=wx.Size(640, 530), style=wx.SIMPLE_BORDER)
1894-
self.figure = Figure()
1894+
self.figure = figure()
18951895
# defines the plot not entirely sure what the numbers in add_subplot mean
18961896
self.axes = self.get_fig().add_subplot(111)
18971897
self.canvas = FigureCanvas(self, -1, self.get_fig())
@@ -2022,6 +2022,9 @@ def draw_complexity_plot(self):
20222022
# self.get_axes().locator_params(axis='x', nbins=8)
20232023

20242024
for yvals in self.get_y():
2025+
# Prevent negative input into log10
2026+
if np.any(yvals < 0) :
2027+
raise Exception("Y-values cannot be negative because of log scale.")
20252028
# scatter log of complexity values
20262029
scatterList.append(self.get_axes().scatter(self.get_x(), np.log10(yvals), marker="o", s=8))
20272030

@@ -2070,7 +2073,7 @@ def __init__(self, parent, x, xr, y, cvf, scale):
20702073

20712074
self.cvf = cvf
20722075
self.scale = scale
2073-
self.figure = Figure()
2076+
self.figure = figure()
20742077
# defines the plot not entirely sure what the numbers in add_subplot mean
20752078
self.axes = self.get_fig().add_subplot(111)
20762079

@@ -2917,7 +2920,7 @@ def __init__(self, parent):
29172920
# gets the Panel properties
29182921
wx.Panel.__init__(self, parent, size=wx.Size(640, 480), style=wx.SIMPLE_BORDER)
29192922

2920-
self.figure = Figure()
2923+
self.figure = figure()
29212924
# defines the plot not entirely sure what the numbers in add_subplot mean
29222925
self.axes = self.get_fig().add_subplot(111)
29232926
self.canvas = FigureCanvas(self, -1, self.get_fig())

0 commit comments

Comments
 (0)