metadata
license: apache-2.0
task_categories:
- text-generation
language:
- en
tags:
- code
- python
- doctest
- transpilation
- rust
size_categories:
- n<1K
Python Doctest Corpus
A curated corpus of Python doctest examples designed for training Python-to-Rust transpilers and testing code translation systems.
Dataset Description
This dataset contains Python function signatures, doctest inputs, and expected outputs that serve as high-quality training data for:
- Transpilation training: Teaching models to translate Python patterns to Rust
- Test validation: Verifying that transpiled code produces correct outputs
- Code understanding: Benchmarking code comprehension systems
Schema
| Column | Type | Description |
|---|---|---|
source |
string | Source project identifier |
version |
string | Git commit SHA or version |
module |
string | Module path (e.g., example_math.math_tool) |
function |
string | Function name being tested |
input |
string | Python doctest input (e.g., >>> square(5)) |
expected |
string | Expected output value |
signature |
string | Full Python function signature with type hints |
Quality Score
Quality score validated using alimentar quality score --profile doctest-corpus:
- Grade: B (90.3%)
- Critical Checks: All passing
- High Priority Checks: All passing
Example
def square(x: int) -> int:
"""
>>> square(5)
25
>>> square(0)
0
"""
return x * x
Becomes:
{
"source": "reprorusted-python-cli",
"function": "square",
"input": ">>> square(5)",
"expected": "25",
"signature": "def square(x: int) -> int"
}
Usage
from datasets import load_dataset
dataset = load_dataset("paiml/python-doctest-corpus")
for example in dataset["train"]:
print(f"{example['function']}: {example['input']} -> {example['expected']}")
License
Apache 2.0
Citation
@dataset{python_doctest_corpus,
author = {PAIML},
title = {Python Doctest Corpus},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/datasets/paiml/python-doctest-corpus}
}