Sample

pyint-8c4942113471-I08

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

Matched original source

Lines22

Scores

MethodScoreScale
Posnett0.9680–1; higher is more readable
Dorn0.850–1; higher is more readable
Mi0.7150–1; higher is more readable
LLOC12Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5620–1; higher is more readable

Views

Source code

from __future__ import annotations class FrozenError(AttributeError): """ A frozen/immutable instance or attribute have been attempted to be modified. It mirrors the behavior of ``namedtuples`` by using the same error message and subclassing `AttributeError`. .. versionadded:: 20.1.0 """ def __init__(self): morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature msg = "can't set attribute" super().__init__(msg) self.msg = msg

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Source linesThe number of non-empty source lines.22+8.8
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.235.022−7.756
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.345−6.518

Intercept 8.87 + feature contributions = 3.396 (log-odds).
Score = sigmoid(3.396) = 0.968.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.031+0.637
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.74.565+0.399
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.77.957+0.363
Indentation frequencyHow rapidly indentation changes from line to line.14−0.253
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.23+0.222
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.21.911−0.104

Intercept 0.07 + feature contributions = 1.733 (log-odds).
Score = sigmoid(1.733) = 0.85.

Score0.715
Score12
Run 1

The code is structurally sound and follows standard conventions for custom exceptions, with a clear class docstring and proper inheritance. However, the __init__ method contains a confusing, irrelevant block of code about temperatures that has no connection to the class's purpose. This significantly harms clarity of intent and reading flow, as a reader expects an exception initializer to focus solely on setting up the error message. The temperature variables create unnecessary length and distract from the logical flow. The error message creation itself is clean, and the use of super() is correct. Overall, the class would be quite readable if the extraneous temperature logic were removed, but as written it introduces ambiguity and reduces maintainability.

Run 2

The code is logically structured and has a clear purpose at a high level: define a custom FrozenError exception that mirrors namedtuple behavior. However, there are significant readability issues. The `__init__` method contains unrelated temperature variables (`morning_temperature`, `evening_temperature`, `lower_temperature`) that serve no purpose and are never used meaningfully; this muddies intent. Nesting is minimal, which is good, but the inclusion of dead code breaks clarity of intent and violates action granularity — unrelated operations are grouped together. The reading flow is disrupted by these irrelevant statements, making the code unnecessarily long and confusing. The docstring is descriptive and helpful, but the overall implementation would benefit from removing the unused temperature logic and directly assigning the error message.

Run 3

The code is clean, well-documented, and logically organized. The class definition is straightforward, with a clear constructor and a helpful docstring. The sequence of assignments at the start of __init__ is unnecessary and confusing—variables like morning_temperature, evening_temperature, and lower_temperature have no relation to the error message being generated. This creates ambiguity in intent, making the reader wonder why they exist. Additionally, multiple assignments inside the __init__ slightly reduce clarity despite flat nesting and concise length. The error message is clear and mirrors namedtuples behavior, which is good. Overall, the structure is readable, but the extraneous temperature logic detracts from the clarity and purpose of the class. Removing that block would make the code highly readable.

Run 1

Code Structure: The exception class and initializer are logically organized, but unrelated temperature calculations distract from exception initialization. Nesting: A single shallow conditional is easy to follow. Clarity of intent: The class name, inheritance, and docstring clearly convey an immutable-attribute error, but the unused temperature calculation obscures the initializer's purpose. Code length: The snippet is short, yet five unnecessary calculation lines add avoidable noise. Action granularity: Each statement performs one action per line, making individual operations easy to read. Reading flow: Formatting and descriptive names support readability, but the transition from temperature comparison to error-message initialization is disjointed.

Run 2

Code Structure: The exception class is logically organized, but unrelated temperature calculations disrupt its constructor. Nesting: A single shallow conditional is easy to follow. Clarity of intent: The class name, inheritance, docstring, and error message clearly convey an immutability error; however, the unused temperature calculation obscures the constructor's purpose. Code length: The code is short overall, but five temperature-related lines are unnecessary to the exception behavior. Action granularity: Each statement performs one action, with no compressed or compound statements. Reading flow: Formatting and descriptive variable names support easy scanning, but the abrupt shift from temperature comparison to exception initialization interrupts the otherwise natural flow.

Run 3

Code Structure: The exception class is logically organized, but unrelated temperature calculations clutter its initializer. Nesting: A single shallow conditional is easy to follow. Clarity of intent: The class name, inheritance, docstring, and error message clearly communicate an immutability exception; however, the unused temperature calculation obscures the initializer's purpose. Code length: The snippet is short overall, but several unnecessary lines could be removed without changing the exception's behavior. Action granularity: Each statement performs one action, with straightforward assignments and a clear superclass call. Reading flow: The documentation naturally leads into initialization, but the temperature-related detour interrupts the otherwise coherent flow.