Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Don't force matplotlib backend names to be lowercase
  • Loading branch information
ianthomas23 committed Jun 28, 2024
commit 4d2c9e32619254c1ea170e897f2c3220ab3419e8
2 changes: 1 addition & 1 deletion IPython/core/magics/pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def matplotlib(self, line=''):
% _list_matplotlib_backends_and_gui_loops()
)
else:
gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
gui, backend = self.shell.enable_matplotlib(args.gui)
self._show_matplotlib_backend(args.gui, backend)

@skip_doctest
Expand Down
24 changes: 24 additions & 0 deletions IPython/core/tests/test_pylabtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,27 @@ def test_backend_entry_point():
def test_backend_unknown():
with pytest.raises(RuntimeError if pt._matplotlib_manages_backends() else KeyError):
pt.find_gui_and_backend("name-does-not-exist")


@dec.skipif(not pt._matplotlib_manages_backends())
def test_backend_module_name_case_sensitive():
# Matplotlib backend names are case insensitive unless explicitly specified using
# "module://some_module.some_name" syntax which are case sensitive for mpl >= 3.9.1
all_lowercase = "module://matplotlib_inline.backend_inline"
some_uppercase = "module://matplotlib_inline.Backend_inline"
ip = get_ipython()
mpl3_9_1 = matplotlib.__version_info__ >= (3, 9, 1)

ip.enable_matplotlib(all_lowercase)
if mpl3_9_1:
with pytest.raises(RuntimeError):
ip.enable_matplotlib(some_uppercase)
else:
ip.enable_matplotlib(some_uppercase)

ip.run_line_magic("matplotlib", all_lowercase)
if mpl3_9_1:
with pytest.raises(RuntimeError):
ip.run_line_magic("matplotlib", some_uppercase)
else:
ip.run_line_magic("matplotlib", some_uppercase)