Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d2c9e3

Browse files
committed
Don't force matplotlib backend names to be lowercase
1 parent a499dbd commit 4d2c9e3

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

IPython/core/magics/pylab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def matplotlib(self, line=''):
100100
% _list_matplotlib_backends_and_gui_loops()
101101
)
102102
else:
103-
gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
103+
gui, backend = self.shell.enable_matplotlib(args.gui)
104104
self._show_matplotlib_backend(args.gui, backend)
105105

106106
@skip_doctest

IPython/core/tests/test_pylabtools.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,27 @@ def test_backend_entry_point():
350350
def test_backend_unknown():
351351
with pytest.raises(RuntimeError if pt._matplotlib_manages_backends() else KeyError):
352352
pt.find_gui_and_backend("name-does-not-exist")
353+
354+
355+
@dec.skipif(not pt._matplotlib_manages_backends())
356+
def test_backend_module_name_case_sensitive():
357+
# Matplotlib backend names are case insensitive unless explicitly specified using
358+
# "module://some_module.some_name" syntax which are case sensitive for mpl >= 3.9.1
359+
all_lowercase = "module://matplotlib_inline.backend_inline"
360+
some_uppercase = "module://matplotlib_inline.Backend_inline"
361+
ip = get_ipython()
362+
mpl3_9_1 = matplotlib.__version_info__ >= (3, 9, 1)
363+
364+
ip.enable_matplotlib(all_lowercase)
365+
if mpl3_9_1:
366+
with pytest.raises(RuntimeError):
367+
ip.enable_matplotlib(some_uppercase)
368+
else:
369+
ip.enable_matplotlib(some_uppercase)
370+
371+
ip.run_line_magic("matplotlib", all_lowercase)
372+
if mpl3_9_1:
373+
with pytest.raises(RuntimeError):
374+
ip.run_line_magic("matplotlib", some_uppercase)
375+
else:
376+
ip.run_line_magic("matplotlib", some_uppercase)

0 commit comments

Comments
 (0)