/usr/share/pyshared/guiqwt/tests/computations.py is in python-guiqwt 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # -*- coding: utf-8 -*-
#
# Copyright © 2009-2010 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guiqwt/__init__.py for details)
"""Plot computations test"""
from __future__ import unicode_literals
SHOW = True # Show test in GUI-based test launcher
from guiqwt.plot import CurveDialog
from guiqwt.builder import make
def plot( *items ):
win = CurveDialog(edit=False, toolbar=True)
plot = win.get_plot()
for item in items:
plot.add_item(item)
win.show()
win.exec_()
def test():
"""Test"""
# -- Create QApplication
import guidata
_app = guidata.qapplication()
# --
from numpy import linspace, sin, trapz
x = linspace(-10, 10, 1000)
y = sin(sin(sin(x)))
curve = make.curve(x, y, "ab", "b")
range = make.range(-2, 2)
disp0 = make.range_info_label(range, 'BR', "x = %.1f ± %.1f cm",
title="Range infos")
disp1 = make.computation(range, "BL", "trapz=%g",
curve, lambda x, y: trapz(y, x))
disp2 = make.computations(range, "TL",
[(curve, "min=%.5f", lambda x, y: y.min()),
(curve, "max=%.5f", lambda x, y: y.max()),
(curve, "avg=%.5f", lambda x, y: y.mean())])
legend = make.legend("TR")
plot( curve, range, disp0, disp1, disp2, legend)
if __name__ == "__main__":
test()
|