Skip to content

Commit fecb3c0

Browse files
committed
API: rename mg.show -> mg.display
Having a conversation about this it was impossible to keep straight with the two meanings of `show`. closes #16
1 parent ac05a41 commit fecb3c0

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

docs/source/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Select the backend
1515
mpl_gui.select_gui_toolkit
1616

1717

18-
Show
19-
----
18+
Display
19+
-------
2020

2121
.. autosummary::
2222
:toctree: _as_gen
2323
:nosignatures:
2424

2525

26-
mpl_gui.show
26+
mpl_gui.display
2727

2828

2929
Interactivity

docs/source/index.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ track of the created figures and shows them on exit ::
143143

144144

145145
This will create 3 figures and block on ``__exit__``. The blocking
146-
behavior depends on ``mg.is_interacitve()`` (and follow the behavior of
147-
``mg.show`` or can explicitly controlled via the *block* keyword argument).
146+
behavior depends on `~mpl_gui.is_interactive()` (and follow the behavior of
147+
`.display` and `.FigureRegistry.show` can explicitly controlled via the *block* keyword argument).
148148

149149
The `.registry` module is implemented by having a singleton `.FigureRegistry`
150150
at the module level.
@@ -164,7 +164,7 @@ explicitly available ::
164164

165165
fig2 = Figure()
166166

167-
mg.show(fig1, fig2)
167+
mg.display(fig1, fig2)
168168

169169

170170
which will show both figures and block until they are closed. As part of the
@@ -182,23 +182,23 @@ Similar to `plt.ion<matplotlib.pyplot.ion>` and
182182
print(mg.is_interactive())
183183
fig = Figure()
184184

185-
mg.show([fig]) # will not block
185+
mg.display([fig]) # will not block
186186

187187
mg.ioff()
188188
print(mg.is_interactive())
189-
mg.show(fig) # will block!
189+
mg.display(fig) # will block!
190190

191191

192192
As with `plt.show<matplotlib.pyplot.show>`, you can explicitly control the
193-
blocking behavior of `mg.show<mpl_gui.show>` via the *block* keyword argument ::
193+
blocking behavior of `mg.display<mpl_gui.display>` via the *block* keyword argument ::
194194

195195
import mpl_gui as mg
196196
from matplotlib.figure import Figure
197197

198198
fig = Figure(label='control blocking')
199199

200-
mg.show(fig, block=False) # will never block
201-
mg.show(fig, block=True) # will always block
200+
mg.display(fig, block=False) # will never block
201+
mg.display(fig, block=True) # will always block
202202

203203

204204
The interactive state is shared Matplotlib and can also be controlled with

mpl_gui/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
_log = logging.getLogger(__name__)
4747

4848

49-
def show(*figs, block=None, timeout=0):
49+
def display(*figs, block=None, timeout=0):
5050
"""
5151
Show the figures and maybe block.
5252
@@ -247,7 +247,7 @@ def show_all(self, *, block=None, timeout=None):
247247
if timeout is None:
248248
timeout = self._timeout
249249
self._ensure_all_figures_promoted()
250-
show(*self.figures, block=self._block, timeout=self._timeout)
250+
display(*self.figures, block=self._block, timeout=self._timeout)
251251

252252
# alias to easy pyplot compatibility
253253
show = show_all
@@ -264,7 +264,7 @@ def close_all(self):
264264
4. drops its hard reference to the Figure
265265
266266
If the user still holds a reference to the Figure it can be revived by
267-
passing it to `mpl_gui.show`.
267+
passing it to `mpl_gui.display`.
268268
269269
"""
270270
for fig in list(self.figures):
@@ -368,7 +368,7 @@ def __enter__(self):
368368
def __exit__(self, exc_type, exc_value, traceback):
369369
if exc_value is not None and not self._forgive_failure:
370370
return
371-
show(*self.figures, block=self._block, timeout=self._timeout)
371+
display(*self.figures, block=self._block, timeout=self._timeout)
372372

373373

374374
# from mpl_gui import * # is a langauge miss-feature

mpl_gui/_manage_interactive.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ def is_interactive():
1414
1515
- newly created figures will be shown immediately;
1616
- figures will automatically redraw on change;
17-
- `mpl_gui.show` will not block by default.
17+
- `.display` will not block by default.
1818
- `mpl_gui.FigureContext` will not block on ``__exit__`` by default.
1919
2020
In non-interactive mode:
2121
2222
- newly created figures and changes to figures will not be reflected until
2323
explicitly asked to be;
24-
- `mpl_gui.show` will block by default.
24+
- `.display` will block by default.
2525
- `mpl_gui.FigureContext` will block on ``__exit__`` by default.
2626
2727
See Also
2828
--------
2929
ion : Enable interactive mode.
3030
ioff : Disable interactive mode.
31-
mpl_gui.show : Show all figures (and maybe block).
31+
mpl_gui.display : Show all figures (and maybe block).
3232
"""
3333
return _is_interact()
3434

@@ -89,7 +89,7 @@ def ioff():
8989
--------
9090
ion : Enable interactive mode.
9191
is_interactive : Whether interactive mode is enabled.
92-
mpl_gui.show : Show all figures (and maybe block).
92+
mpl_gui.display : Show all figures (and maybe block).
9393
9494
Notes
9595
-----
@@ -124,7 +124,7 @@ def ion():
124124
--------
125125
ioff : Disable interactive mode.
126126
is_interactive : Whether interactive mode is enabled.
127-
mpl_gui.show : Show all figures (and maybe block).
127+
mpl_gui.display : Show all figures (and maybe block).
128128
129129
Notes
130130
-----

mpl_gui/tests/test_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_no_pyplot():
1414
def test_promotion():
1515
fig = mg.Figure(label="test")
1616
assert fig.canvas.manager is None
17-
mg.show(*[fig], block=False)
17+
mg.display(*[fig], block=False)
1818
assert fig.canvas.manager is not None
1919

2020

@@ -32,7 +32,7 @@ def test_ion():
3232
ax = fig.subplots()
3333
(ln,) = ax.plot(range(5))
3434
ln.set_color("k")
35-
mg.show(*[fig], timeout=1)
35+
mg.display(*[fig], timeout=1)
3636
assert "start_event_loop" not in fig.canvas.call_info
3737

3838

@@ -43,7 +43,7 @@ def test_ioff():
4343

4444
def test_timeout():
4545
fig = mg.Figure()
46-
mg.show(*[fig], block=True, timeout=1)
46+
mg.display(*[fig], block=True, timeout=1)
4747
assert "start_event_loop" in fig.canvas.call_info
4848

4949

@@ -89,7 +89,7 @@ def test_close_all():
8989

9090
# test revive
9191
old_canvas = fig.canvas
92-
mg.show(fig)
92+
mg.display(fig)
9393
assert fig.canvas is not old_canvas
9494

9595

0 commit comments

Comments
 (0)