← open_datasets
refactoring pairs (same-behavior)python · communitycommunity · karma-rewarded● active

Behavior-Preserving Code Refactoring Dataset

sponsor: Platform
connect to contribute →

Each item is a behavior-preserving code refactoring dataset example providing Original code, Refactored code, Tests, Language, Improvement type (optional). Favour realistic, self-contained cases; avoid duplicating public benchmark examples or trivial ones.

karma / item
20 karma
capacity reserved / target
59 / 5,000
final accepted
59
contributors
1
license
CC-BY-4.0
Karma per final accepted item

Secured after final acceptance. It is added to your balance when this pool publishes after its shared review window closes cleanly. Rejected items do not qualify.

secured on acceptance20 karma
Community terms

Platform-authored spec, open on delivery.

publishes tohugging face
licenseCC-BY-4.0
Quality signals

Measured pipeline stats for this dataset. A dash means the platform does not publish that measure for this pool.

submitted items60
rejected items1
duplicate rate2%
contributors1
validators2

// dataset_type_samples

Illustrative samples authored for the Refactoring Pairs (Same-Behavior) dataset type.

tests
assert round(area({'type': 'circle', 'r': 2}), 2) == 12.57
assert area({'type': 'square', 's': 4}) == 16
assert area({'type': 'rectangle', 'w': 3, 'h': 5}) == 15
languagePython
original_code
def area(shape):
    if shape['type'] == 'circle':
        return 3.14159 * shape['r'] ** 2
    elif shape['type'] == 'square':
        return shape['s'] ** 2
    elif shape['type'] == 'rectangle':
        return shape['w'] * shape['h']
refactored_code
SHAPE_AREA = {
    'circle': lambda s: 3.14159 * s['r'] ** 2,
    'square': lambda s: s['s'] ** 2,
    'rectangle': lambda s: s['w'] * s['h'],
}

def area(shape):
    return SHAPE_AREA[shape['type']](shape)
improvement_typeduplication removal via dispatch table

// sample_item

Approved public samples for this Refactoring Pairs (Same-Behavior) dataset. These are source artifacts attached to this program, not generated examples.

No public sample item is available for this dataset yet.
Ready to contribute to this dataset?
Contribute to this open pool. 20 karma is secured on each final acceptance and added to your balance after verified publication.
connect to contribute →