Sample

pyint-44a1283547a2-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines17

Scores

MethodScoreScale
Posnett0.1050–1; higher is more readable
Dorn0.8450–1; higher is more readable
Mi0.5870–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5730–1; higher is more readable

Views

Source code

from __future__ import annotations import re from typing import Any, Dict, List, Tuple import attr import attrs @attr.s(auto_detect=True) class AutoDetect: x: int def __init__(self, x: int): morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature self.x = x

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.346.385−11.431
Source linesThe number of non-empty source lines.17+6.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.254−6.381

Intercept 8.87 + feature contributions = -2.142 (log-odds).
Score = sigmoid(-2.142) = 0.105.

Feature contributions

FeatureValueContribution
(log-odds)
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.50.889+1.51
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.17+0.434
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.411
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.16.712−0.176
Indentation frequencyHow rapidly indentation changes from line to line.17−0.149

Intercept 0.07 + feature contributions = 1.694 (log-odds).
Score = sigmoid(1.694) = 0.845.

Score0.587
Score14
Run 1

The code is largely ambiguous and poorly structured. An AutoDetect class contains an __init__ method that defines unrelated temperature variables and performs a meaningless comparison before assigning a simple x parameter—this obscures intent. Dead code (unused imports: re, typing, attr/attrs duplication) adds clutter, as does the redundant explicit __init__ for a simple attribute, which could be handled by attrs automatically. Logical organization is weak: temperature logic is misplaced and has no connection to the class purpose. Nesting is shallow, but action granularity is muddled—several unrelated operations are grouped. Reading flow is disjointed, with no coherent narrative. The code is not long, but it adds unnecessary complexity for trivial attribute assignment. Overall, it reads as leftover debug or experimental code, making it hard to understand at a glance.

Run 2

The code is generally readable but contains confusing elements. The class AutoDetect uses @attr.s(auto_detect=True), which is unnecessary and potentially confusing since no attr.ib declarations exist. The __init__ method defines temperature variables that have no relationship to the class attribute x, creating ambiguity about intent and poor reading flow. The if-statement and variable assignments add unnecessary complexity and length without purpose. Nesting is minimal and structure is mostly flat, which is good, but action granularity is inconsistent—multiple temperature-related lines do not map to the class's goal. Unused imports (re, Any, Dict, List, Tuple, attrs) further reduce clarity. The core logic could be a one-line assignment. Overall, the code has reasonable formatting but suffers from misleading context and dead code, lowering its readability score.

Run 3

The code is short and syntactically clear, but it is poorly structured and confusing in intent. The class uses both `attr.s` and `@auto_detect=True`, then defines a manual `__init__` that overwrites what attrs would generate, making the decorator redundant and misleading. The `__init__` contains a block of irrelevant temperature logic that does not affect `self.x`, which severely obscures the purpose. While nesting is flat and there is one action per line, the reading flow is unnatural because the reader expects a simple assignment but instead encounters dead code. The `from __future__ import annotations` and multiple imports suggest a larger context, but none are used in this snippet. Overall, the code is concise but fails in clarity of intent and logical organization, leading to a low readability score.

Run 1

Code Structure: The class and initializer are logically organized, but unused imports and unrelated temperature calculations add clutter. Nesting: Only one shallow conditional, making control flow easy to follow. Clarity of intent: Assigning x is clear, but the purpose of calculating an unused lower_temperature is ambiguous. Code length: Short overall, though several lines do not contribute to the object's initialization. Action granularity: Each line performs a single action, with descriptive variable names. Reading flow: Straightforward top-to-bottom execution, but the temperature logic interrupts the natural flow from the initializer argument to self.x.

Run 2

Code Structure: Imports and the class are logically organized, but unused imports and unrelated temperature calculations add clutter. Nesting: A single shallow conditional is easy to follow. Clarity of intent: The class stores x, but the unused temperature calculation obscures the constructor's purpose, and the class name is generic. Code length: Short overall, though several lines do not contribute to the object's state or behavior. Action granularity: Each statement performs one action, making individual lines easy to understand. Reading flow: The layout is straightforward, but irrelevant calculations interrupt the natural flow from constructor input to assignment.

Run 3

Code Structure: Imports and the class are logically organized, but unused imports and unrelated temperature calculations add clutter. Nesting: Only one shallow conditional makes the code easy to follow. Clarity of intent: The class stores x, but the unused temperature calculation obscures the constructor's purpose. Code length: Short overall, though several lines could be removed without changing its meaningful behavior. Action granularity: Each statement performs one clear action. Reading flow: Formatting and descriptive temperature names support readability, but the shift from temperature comparison to assigning x feels disconnected.