Sample
pyint-ac2d553ca8df-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.569 | 0–1; higher is more readable |
| Dorn | 0.901 | 0–1; higher is more readable |
| Mi | 0.699 | 0–1; higher is more readable |
| LLOC | 10 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 17.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.33 | 0–20; mean of three runs |
| BTTF | 0.811 | 0–1; higher is more readable |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (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. | 218.725 | −7.218 |
| 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.384 | −6.576 |
| Source linesThe number of non-empty source lines. | 13 | +5.2 |
Intercept 8.87 + feature contributions = 0.277 (log-odds).
Score = sigmoid(0.277) = 0.569.
Feature contributions
| Feature | Value | Contribution (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. | 33.429 | +2.249 |
| 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. | 14 | +0.541 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 13 | −0.287 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.068 | +0.278 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 12.686 | −0.233 |
Intercept 0.07 + feature contributions = 2.212 (log-odds).
Score = sigmoid(2.212) = 0.901.
| Score | 0.699 |
|---|
| Score | 10 |
|---|
Run 1
The code is very readable with clear structure and intent. It uses modern Python features (from __future__ import annotations, attrs library) and defines a simple class with a single attribute. Each import is on a separate line, the class definition is clean, and the __init__ method clearly assigns the attribute. One minor point: the explicit __init__ method is redundant if auto_detect=True is used, which could be slightly confusing. However, overall the code is concise, flat, and easy to follow.
Run 2
The code is concise, well-structured, and clearly intended. It demonstrates a straightforward example of using `attrs` with `auto_detect=True` and an explicit `__init__` override. Structure is logical: imports are organized, class definition follows a clear pattern. Nesting is minimal, action granularity is one action per line, and reading flow is natural. The only minor drawback is potential ambiguity about why `auto_detect=True` is used alongside a manual `__init__`, and the slight redundancy in redefining `x` as a field and in `__init__`. Additionally, the import of `copy`, `re`, `sys`, and `Any` is unused, which detracts from clarity. Still, the core code is very readable.
Run 3
The code is highly readable due to its concise and well-structured nature. The imports are cleanly organized, and the class definition is simple and unambiguous. The use of the `@attrs.define` decorator with `auto_detect=True` is clear, and the manual `__init__` method, while redundant given attrs' capabilities, is explicit about its purpose. Nesting is minimal, and each logical action is separated by line breaks. The reading flow is natural: imports, decorator, class, method. The only slight reduction in score stems from the redundant manual `__init__` which could be omitted for brevity, but it does not harm clarity. Overall, this is very readable code.
Run 1
Code Structure: Imports and a small class are logically organized, though several imports are unused and spacing between top-level definitions could improve. Nesting: Minimal, with only a class and its initializer. Clarity of intent: The typed field and straightforward assignment clearly describe initialization, but the purpose of auto_detect=True and the explicit initializer alongside attrs may require library knowledge. Code length: Very concise, although unused imports add clutter. Action granularity: Each line performs a single action. Reading flow: Natural progression from imports to class definition to initialization, with no tangled control flow.
Run 2
Code Structure: Imports and the class are logically organized, although copy, re, sys, and Any are unused. Nesting: Minimal, with only a class and its initializer. Clarity of intent: The typed x attribute and straightforward assignment are clear, but the generic class name and unexplained auto_detect setting obscure the broader purpose. Code length: Very concise, though unused imports add clutter and the explicit initializer duplicates functionality attrs could normally generate. Action granularity: Each line performs a single action. Reading flow: Natural top-to-bottom progression, with minor spacing improvements possible between import groups and before the class.
Run 3
Code Structure: Imports and the class are logically organized, though several imports are unused. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The typed attribute and explicit initializer clearly describe a simple data container, but the generic class name and auto-detection setting provide little context. Code length: Very concise, although attrs could generate the initializer, making the explicit method potentially redundant. Action granularity: Each line performs a single action. Reading flow: Natural top-to-bottom progression; separating standard-library and third-party imports and adding another blank line before the class would improve formatting.