-
Notifications
You must be signed in to change notification settings - Fork 5
/
UAT.py
155 lines (114 loc) · 3.15 KB
/
UAT.py
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import argparse
import sys
import matplotlib as mpl
import mpl_gui as mg
from matplotlib.figure import Figure
# ensure no pyplot!
assert sys.modules.get("matplotlib.pyplot", None) is None
sys.modules["matplotlib.pyplot"] = None
parser = argparse.ArgumentParser(
description="User Acceptance Tests for mpl-gui.",
epilog=(
"This script runs through several scenarios and prints out prompts explaining the expected behavior. "
"The figures will need to be closed to continue the script. "
),
)
parser.add_argument(
"backend",
type=str,
help="The backend to use. Can be anything that `mpl.use` accepts",
)
args = parser.parse_args()
target = args.backend
# this is how to force the right Qt binding
if target.lower().startswith("qt5"):
import PyQt5.QtWidgets # noqa
elif target.lower().startswith("qt"):
import PyQt6.QtWidgets # noqa
mpl.use(target, force=True)
fig1 = Figure(label="A Label!")
fig2 = Figure()
print(
"""
You should see two figures with window titles of
- "A Label!"
- "Figure 0"
both should be empty and the process should block until both
are closed (the keybinding 'q' should work).
"""
)
mg.show([fig1, fig2])
mg.ion()
fig = Figure()
print(f"Interactive mode is on: {mg.is_interactive()}")
mg.show([fig]) # will not block
print("A (implicitly) non-blocking show was just called.")
mg.ioff()
print(mg.is_interactive())
print(f"Interactive mode is on: {mg.is_interactive()}")
print(
"""
You should see one open figure with the title
- Figure 2
and the process should again block until it is closed.
"""
)
mg.show([fig]) # will block!
fig = Figure(label="control blocking")
mg.show([fig], block=False) # will never block
print("A (implicitly) non-blocking show was just called.")
print(
"""
You should see one open figure with the title
- control blocking
and the process should again block until it is closed.
"""
)
mg.show([fig], block=True) # will always block
fig1 = mg.figure()
fig2, axs = mg.subplots(2, 2)
fig3, axd = mg.subplot_mosaic("AA\nBC")
print(
"""
You should see three open figure with the titles
- Figure 4
- Figure 5
- Figure 6
and the process should again block until it is closed. One will
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
"""
)
mg.show([fig1, fig2, fig3])
fr = mg.FigureRegistry()
fr.figure()
fr.subplots(2, 2)
fr.subplot_mosaic("AA\nBC")
print(
"""
You should see three open figure with the titles
- Figure 0
- Figure 1
- Figure 2
and the process should again block until it is closed. One will
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
"""
)
fr.show_all() # will show all three figures
# fr.show() # alias for pyplot compatibility
# fr.close_all() # will close all three figures
# fr.close("all") # alias for pyplot compatibility
plt = mg.FigureRegistry()
with mg.FigureContext() as fc:
fc.subplot_mosaic("AA\nBC")
fc.figure()
fc.subplots(2, 2)
print(
"""
You should see three open figure with the titles
- Figure 0
- Figure 1
- Figure 2
and the process should again block until it is closed. One will
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
"""
)