Sample
pyint-1fa5abadd0ac-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.002 | 0–1; higher is more readable |
| Dorn | 0.697 | 0–1; higher is more readable |
| Mi | 0.535 | 0–1; higher is more readable |
| LLOC | 29 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 17.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.719 | 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. | 1056.775 | −34.874 |
| Source linesThe number of non-empty source lines. | 66 | +26.4 |
| 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.513 | −6.769 |
Intercept 8.87 + feature contributions = -6.372 (log-odds).
Score = sigmoid(-6.372) = 0.002.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 67 | −1.336 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 46 | +0.854 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 46 | −0.635 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.039 | +0.566 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 65.833 | +0.51 |
| 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 | +0.404 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 74.612 | +0.399 |
Intercept 0.07 + feature contributions = 0.833 (log-odds).
Score = sigmoid(0.833) = 0.697.
| Score | 0.535 |
|---|
| Score | 29 |
|---|
Run 1
The code demonstrates excellent readability through clear structure and organization. Imports are logically grouped with a mix of standard library, third-party, and local modules. The Factory class has a well-documented purpose with a clear docstring explaining its usage and parameters. Each method has a single, focused responsibility - __init__, __getstate__, and __setstate__ each perform one clear action. The code uses modern Python features appropriately (__slots__, zip with strict=True, type hints) without sacrificing clarity. Naming conventions are consistent and descriptive. The use of __slots__ reduces memory overhead while the concise implementation avoids unnecessary verbosity. Comments are minimal but meaningful, with version annotations where relevant. The only minor deduction is that some context about the broader attrs library would help understand this class's role in the larger system, but within its scope, it's exceptionally clear and well-structured.
Run 2
The code is well-structured and highly readable. It follows a clear logical order: imports, class definition, docstrings, methods. Nesting is minimal, with class methods flat and separated. Intent is clearly communicated through descriptive docstrings and parameter names. The code is concise but not overly so, with no unnecessary repetition. Action granularity is good—each line typically does one thing, such as `return tuple(getattr(self, name) for name in self.__slots__)`. Reading flow is natural and consistent with Python conventions. Minor deductions: the use of `zip(..., strict=True)` may be less familiar to some readers, and the `Factory` class could benefit from a type hint for `factory`, though this is not a major readability issue.
Run 3
The code is well-structured with clear separation between imports, class definition, and methods. There is minimal nesting and each method has a single, clear responsibility. The docstrings effectively communicate intent, especially for the Factory class and its pickle-related methods. Variable names are descriptive and consistent. The Factory class uses class-level attributes and slots appropriately for performance and clarity. Some minor improvements could include adding docstrings to individual attributes and slightly condensing redundant docstrings (e.g., 'Play nice with pickle' repeated), but overall the code is highly readable, concise, and follows Python best practices.
Run 1
Code Structure: The Factory class is logically organized, with initialization followed by serialization methods; however, many imports are unused in this snippet. Nesting: Methods remain shallow, with only a single loop. Clarity of intent: Descriptive names and a detailed class docstring clearly explain factory behavior, although the pickle method docstrings provide little detail. Code length: The implementation is concise, but the import list is disproportionate to the shown functionality. Action granularity: Each statement performs one clear action; the generator expression is compact and readable. Reading flow: The class reads naturally from purpose to initialization to state handling, though additional spacing between import groups and the class would improve visual separation.
Run 2
Code Structure: The class is logically organized, with slots, initialization, and serialization methods clearly separated; many imports are unused in this excerpt and add clutter. Nesting: Control flow is shallow, with only a simple loop in __setstate__. Clarity of intent: Descriptive names and a detailed class docstring explain the factory's purpose and takes_self behavior, although the pickle-method docstrings are informal and do not explain the slot-based state representation. Code length: The implementation is concise; documentation is useful but relatively long compared with the executable code. Action granularity: Each statement performs a single clear action, and the tuple comprehension remains straightforward. Reading flow: Methods follow a natural order, making the class easy to scan, though the extensive import block delays reaching the relevant implementation.
Run 3
Code Structure: The class is logically organized into initialization and serialization methods, although the many unused imports distract from this isolated snippet. Nesting: Methods are flat, with only one simple loop. Clarity of intent: Descriptive names and a detailed class docstring explain the factory's purpose and takes_self behavior; serialization docstrings are less specific. Code length: Implementation is concise, though imports and documentation dominate the short class. Action granularity: Each statement performs a single clear action, and the generator expression is straightforward. Reading flow: Methods follow a natural order, and consistent formatting supports easy scanning; a clearer separation between imports and the class would improve presentation.