Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ipython@9.5.x
tile.json

tessl/pypi-ipython

tessl install tessl/pypi-ipython@9.5.0

IPython: 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%

task.mdevals/scenario-10/

Task: Custom Magic Command System

Overview

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.

Dependencies { .dependencies }

IPython { .dependency }

Provides interactive Python shell with extensible magic command system.

Requirements

Line Magic: Transform Text

Create a line magic command %transform that applies various text transformations. The command should:

  • Accept a transformation type as the first argument: upper, lower, reverse, or title
  • Accept the text to transform as remaining arguments
  • Return the transformed text
  • Support argument parsing with proper error handling for invalid transformation types

Cell Magic: Multi-line Transformation

Create a cell magic command %%transform_block that applies transformations to multi-line text. The command should:

  • Accept a transformation type as an argument on the first line
  • Apply the transformation to each line of the cell content
  • Display the transformed output
  • Support the same transformation types as the line magic: upper, lower, reverse, title

Dual-mode Magic: Statistics

Create a line/cell magic command %stats (or %%stats) that provides text statistics. The command should:

  • As a line magic: Accept text as arguments and return word count and character count
  • As a cell magic: Process the entire cell content and return word count, character count, and line count
  • Format output clearly showing each statistic

Implementation Files

text_magics.py { .file }

Implementation of the custom magic commands.

test_text_magics.py { .file }

Test suite for the magic commands.

Test Cases

Test 1: Line Magic Transform @test

# 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.

Test 2: Cell Magic Transform @test

%%transform_block title
hello world
python programming
ipython magic

# Expected output:
# Hello World
# Python Programming
# Ipython Magic

Expected: Each line should be transformed to title case.

Test 3: Line/Cell Magic Stats @test

# 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: 3

Expected: Statistics should be calculated correctly for both modes.

Constraints

  • Use IPython's magic command decorators and registration system
  • Implement proper argument parsing using IPython's magic argument utilities
  • Handle invalid transformation types gracefully
  • Ensure magic commands are properly registered and can be loaded as an IPython extension
  • Follow Python naming conventions and best practices

Notes

  • The magic commands should be loadable via %load_ext text_magics
  • Your implementation should define load_ipython_extension() function for proper extension loading
  • Test your implementation in an IPython environment to ensure proper integration