Skip to content

Fix deprecated IPython magic() calls in demo notebooks (issue #1036)#1203

Merged
jlarson4 merged 5 commits intoTransformerLensOrg:devfrom
brainsnog:fix/ipython-magic-deprecation
Mar 16, 2026
Merged

Fix deprecated IPython magic() calls in demo notebooks (issue #1036)#1203
jlarson4 merged 5 commits intoTransformerLensOrg:devfrom
brainsnog:fix/ipython-magic-deprecation

Conversation

@brainsnog
Copy link

Summary

Fixes #1036.

Replaces all uses of the deprecated get_ipython().magic() API with
get_ipython().run_line_magic() across 16 demo notebooks.

IPython.magic() was deprecated in IPython 8.0 (released January 2022)
and removed in later versions, causing notebooks to break when run with
modern IPython installations. The fix splits the combined string argument
into separate name and args parameters as required by the new API:

# Before (broken on IPython >= 8.0)
ipython.magic("load_ext autoreload")
ipython.magic("autoreload 2")

# After (correct)
ipython.run_line_magic("load_ext", "autoreload")
ipython.run_line_magic("autoreload", "2")

Changes

  • Updated 16 notebooks in demos/ with 37 line replacements
  • No logic changes — purely a like-for-like API update
  • All surrounding code left untouched

…rmerLensOrg#1036)

Replace get_ipython().magic() with get_ipython().run_line_magic()
across 16 demo notebooks. The magic() method was deprecated in
IPython 8.0 (2022) and causes notebooks to break with modern
IPython versions.

Fixes TransformerLensOrg#1036
@brainsnog brainsnog marked this pull request as ready for review March 15, 2026 14:25
@jlarson4 jlarson4 changed the base branch from main to dev March 16, 2026 13:35
@jlarson4 jlarson4 merged commit 7784be1 into TransformerLensOrg:dev Mar 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] ipython.magic not working with latest ipython

2 participants