tools: various improvements in gimp-performance-log-viewer.py

Fix int-ratio variable formatting when the input is NaN, which can
happen when calculating the standard deviation, if all the values
are infinite.

Fix keyboard sample-range selection.

Deselect all samples when right-clicking a sample graph.
This commit is contained in:
Ell 2018-09-27 01:09:46 -04:00
parent 9a2999a553
commit d33fb0e7b8

View file

@ -103,9 +103,11 @@ var_types = {
"int-ratio": VariableType (
parse = lambda x: div (*map (int, x.split (":"))),
format = lambda x: "%g:%g" % (
(1, 0) if math.isinf (x) else
(0, 0) if math.isnan (x) else
(1, 0) if x == math.inf else
(-1, 0) if x == -math.inf else
(0, 1) if x == 0 else
(round (100 * x) / 100, 1) if x > 1 else
(round (100 * x) / 100, 1) if abs (x) > 1 else
(1, round (100 / x) / 100)
),
format_numeric = None
@ -719,9 +721,7 @@ class SampleGraph (Gtk.DrawingArea):
def do_button_press_event (self, event):
self.grab_focus ()
if event.button != 1:
return False
if event.button == 1:
i = self.x_to_sample (event.x)
if i is None:
@ -745,25 +745,26 @@ class SampleGraph (Gtk.DrawingArea):
self.update_selection ()
self.grab_add ()
elif event.button == 3:
selection.select (set ())
self.grab_add ()
return True
def do_button_release_event (self, event):
if event.button != 1:
return False
if self.selection is None:
return False
if event.button == 1 or event.button == 3:
self.selection = None
self.grab_remove ()
selection.change_complete ()
self.grab_remove ()
return True
return False
def do_motion_notify_event (self, event):
i = self.x_to_sample (event.x)
@ -846,6 +847,7 @@ class SampleGraph (Gtk.DrawingArea):
selection.select_range (i0, cursor, op)
if len (selection.selection) > 1:
selection.cursor = cursor
selection.cursor_dir = cursor_dir