tessl install tessl/pypi-ipython@9.5.0IPython: Productive Interactive Computing - An advanced interactive computing environment and command shell for Python.
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.09x
Baseline
Agent success rate without this tile
79%
Build a custom magic command system for IPython that provides utilities for text transformation. Your implementation should include both line and cell magic commands with argument parsing support.
Provides interactive Python shell with extensible magic command system.
Create a line magic command %transform that applies various text transformations. The command should:
upper, lower, reverse, or titleCreate a cell magic command %%transform_block that applies transformations to multi-line text. The command should:
upper, lower, reverse, titleCreate a line/cell magic command %stats (or %%stats) that provides text statistics. The command should:
text_magics.py { .file }Implementation of the custom magic commands.
test_text_magics.py { .file }Test suite for the magic commands.
# Load the magic extension
%load_ext text_magics
# Test upper transformation
result = %transform upper hello world
assert result == "HELLO WORLD"Expected: The text "hello world" should be transformed to uppercase.
%%transform_block title
hello world
python programming
ipython magic
# Expected output:
# Hello World
# Python Programming
# Ipython MagicExpected: Each line should be transformed to title case.
# Line magic mode
result = %stats hello world test
assert "Word count: 3" in result
# Cell magic mode
%%stats
This is a test
with multiple lines
and several words
# Expected output should include:
# Word count: 9
# Character count: 47 (or similar, excluding newlines)
# Line count: 3Expected: Statistics should be calculated correctly for both modes.
%load_ext text_magicsload_ipython_extension() function for proper extension loading