Sample

Dorn/python/97

Human rating uses the original dataset scale.

DatasetDorn
Human4.11
Lines48

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett0.0010–1; higher is more readable
60.7Δ 34.0
Dorn0.780–1; higher is more readable
75.5Δ 19.2
Mi0.4080–1; higher is more readable
39.8Δ 54.9
LLOC19Logical lines; fewer is more readable
35.5Δ 59.2
DeepSeek V4 Pro160–20; mean of three runs
84.5Δ 10.2
GPT-6.1 Sol15.330–20; mean of three runs
58.6Δ 36.1
BTTF0.6180–1; higher is more readable
78.3Δ 16.4
Human4.111–5; original rating
94.7

Views

Source code

#!/usr/bin/env python # -*- coding: utf-8 -*- """ A simple demo script showing the use of PyQt timers. Note that if you run this script again before the timer fires, the first timer is cancelled (because the timer object is deleted when you replace the only reference to it, the `timer' name in the global scope. Watch out for this sort of thing when writing your scripts. """ import sys try: import scribus except ImportError,err: print "This script only runs from within Scribus" sys.exit(1) try: import qt except ImportError,err: scribus.messageBox("Scribus - Python Timer", "It seems you don't have PyQt installed. " "This script can't do anything without it. " "You can probably install PyQt from your " "distro's packages. Failing that, you can get " "PyQt from http://www.riverbankcomputing.co.uk .", scribus.BUTTON_OK) sys.exit(1) def msg(): scribus.messageBox("Scribus - Python Timer", "The timer has run out", scribus.BUTTON_OK) def main(): global timer timer = qt.QTimer() timer.connect(timer, qt.SIGNAL("timeout()"), msg) scribus.messageBox("Scribus - Python Timer", "About to start a 5 second timer", scribus.BUTTON_OK) timer.start(5*1000, True) if __name__ == '__main__':

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.849.407−28.03
Source linesThe number of non-empty source lines.48+19.2
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.488−6.732

Intercept 8.87 + feature contributions = -6.693 (log-odds).
Score = sigmoid(-6.693) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.49−0.699
Indentation frequencyHow rapidly indentation changes from line to line.38+0.577
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.73+0.573
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.039+0.562
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.38−0.451
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73+0.373
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.47.892+0.26

Intercept 0.07 + feature contributions = 1.266 (log-odds).
Score = sigmoid(1.266) = 0.78.

Score0.408
Score19
Run 1

The code is well-structured with clear imports, error handling, and separated functions. It uses flat nesting with minimal indentation levels, making control flow easy to follow. Intent is clearly stated in the docstring and function names. The code is concise without unnecessary verbosity. Each action is on its own line, including function calls and timer setup. Reading flow is natural: imports, error checks, function definitions, and main execution. Minor deductions: Python 2 syntax (e.g., `except ImportError,err`, `print` statement) may confuse modern readers, and the global timer variable could be better documented. The try/except blocks are slightly repetitive but acceptably so. Overall, the code is highly readable and maintainable.

Run 2

The code is generally readable: it has a clear structure with imports, a utility function, and a main function. Nesting is minimal and intent is mostly clear. However, readability issues reduce the score. The script uses Python 2 syntax (`except ImportError,err`, `print`), which is obsolete. The docstring is verbose and mixes explanation with a warning that could be more concise. The `main()` function uses `global timer`, which is slightly ambiguous without context. The timer setup is compact but the chained `timer.connect(timer, qt.SIGNAL(...), msg)` combines multiple actions on one line, lowering action granularity. The `if __name__ == '__main__':` block is empty, which disrupts reading flow. Overall, the code is understandable but could be more concise and modernized.

Run 3

The code is clear and logically organized with a simple structure. It has minimal nesting, which helps readability. The variables, functions, and imports are named descriptively, and the code includes comments explaining behavior. However, the use of Python 2 syntax (e.g., `print` statement, `except ImportError, err`) may confuse readers expecting modern Python. The final `if __name__ == '__main__':` lacks a call to `main()`, which makes the script incomplete and slightly ambiguous. The action granularity is mostly one action per line, and the reading flow is natural. Overall, it is quite readable but could benefit from updating the syntax and adding the missing function call.

Run 1

Code Structure: Imports, dependency checks, callback, and timer setup are logically separated, but the final entry-point guard has no body, leaving the script incomplete. Nesting: Shallow nesting makes the code easy to scan. Clarity of intent: The docstring and messages explain the timer demonstration and its lifetime caveat, although names such as msg are generic and the global timer introduces implicit state. Code length: Short and focused; the dependency-installation message is somewhat lengthy but useful. Action granularity: Each statement generally performs one action, and multiline calls remain clear. Reading flow: The progression from dependency checks to callback and setup is natural, but the unfinished entry point abruptly breaks the flow and obscures how main is invoked.

Run 2

Code Structure: Imports, dependency checks, callback, and timer setup are logically separated, but the final main guard has no body, leaving the script incomplete. Nesting: Shallow blocks make the code easy to follow. Clarity of intent: The introductory docstring and user-facing messages clearly explain the timer demonstration; however, names such as msg and the positional True argument are less descriptive. Code length: The script is concise overall, with a somewhat lengthy but useful dependency-error message. Action granularity: Each statement performs a single clear action, and multiline calls remain readable. Reading flow: The progression from dependency checks to callback and setup is natural, but the empty entry-point block interrupts completion. Global timer state adds some cognitive overhead, though its lifetime implications are explicitly documented.

Run 3

Code Structure: Imports, dependency checks, callback, and timer setup are logically separated, though the final entry-point block is incomplete. Nesting: Shallow exception handlers and simple functions make the code easy to scan. Clarity of intent: The introductory docstring and dialog messages clearly explain the timer demo; however, the generic callback name 'msg', global timer state, and positional boolean argument are less explicit. Code length: The script is concise, with a somewhat lengthy but useful dependency error message. Action granularity: Each statement performs one main action, and multiline calls are formatted clearly. Reading flow: Execution proceeds naturally from dependency checks to function definitions, but the empty '__main__' block abruptly interrupts the flow and leaves the intended invocation missing.