File: test_curvebenchmark2.py

package info (click to toggle)
python-qwt 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,396 kB
  • sloc: python: 12,138; makefile: 19; sh: 10
file content (91 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (3)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the MIT License
# Copyright (c) 2015 Pierre Raybaut
# (see LICENSE file for more details)

"""Curve styles"""

SHOW = True  # Show test in GUI-based test launcher

import time

from qtpy.QtCore import Qt

from qwt import QwtSymbol
from qwt.tests import test_curvebenchmark1 as cb
from qwt.tests import utils


class CSWidget(cb.BMWidget):
    def params(self, *args, **kwargs):
        (symbols,) = args
        symb1 = QwtSymbol.make(
            QwtSymbol.Ellipse, brush=Qt.yellow, pen=Qt.blue, size=(5, 5)
        )
        symb2 = QwtSymbol.make(QwtSymbol.XCross, pen=Qt.darkMagenta, size=(5, 5))
        if symbols:
            if kwargs.get("only_lines", False):
                return (
                    ("Lines", symb1),
                    ("Lines", symb1),
                    ("Lines", symb2),
                    ("Lines", symb2),
                )
            else:
                return (
                    ("Sticks", symb1),
                    ("Lines", symb1),
                    ("Steps", symb2),
                    ("Dots", symb2),
                )
        else:
            if kwargs.get("only_lines", False):
                return (
                    ("Lines", None),
                    ("Lines", None),
                    ("Lines", None),
                    ("Lines", None),
                )
            else:
                return (
                    ("Sticks", None),
                    ("Lines", None),
                    ("Steps", None),
                    ("Dots", None),
                )


class CurveBenchmark2(cb.CurveBenchmark1):
    TITLE = "Curve styles"
    SIZE = (1000, 800)

    def __init__(self, max_n=1000, parent=None, unattended=False, **kwargs):
        super(CurveBenchmark2, self).__init__(
            max_n=max_n, parent=parent, unattended=unattended, **kwargs
        )

    def run_benchmark(self, max_n, unattended, **kwargs):
        for points, symbols in zip(
            (max_n / 10, max_n / 10, max_n, max_n), (True, False) * 2
        ):
            t0 = time.time()
            symtext = "with%s symbols" % ("" if symbols else "out")
            widget = CSWidget(2, points, symbols, **kwargs)
            title = "%d points" % points
            description = "%d plots with %d curves of %d points, %s" % (
                widget.plot_nb,
                widget.curve_nb,
                points,
                symtext,
            )
            self.process_iteration(title, description, widget, t0)


def test_curvebenchmark2():
    """Curve styles benchmark example"""
    utils.test_widget(CurveBenchmark2, options=False)


if __name__ == "__main__":
    test_curvebenchmark2()