Sample

Schnappinger/aoi/artofillusion.procedural.AbsModule

Human rating uses the original dataset scale.

Human3.93
Lines66

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
48.8Δ 13.2
Scalabrino0.5770–1; higher is more readable
18.2Δ 43.9
Dorn0.2330–1; higher is more readable
42.9Δ 19.1
Mi0.460–1; higher is more readable
28.7Δ 33.3
LLOC19Logical lines; fewer is more readable
61.6Δ 0.5
DeepSeek V4 Pro170–20; mean of three runs
66.8Δ 4.8
GPT-6.1 Sol16.670–20; mean of three runs
48.0Δ 14.0
BTTF0.3410–1; higher is more readable
25.7Δ 36.3
Human3.931–4; original rating
62.0

Views

Source code

/* This is a Module which outputs the absolute value of a number. */ /* Copyright (C) 2000 by Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion.procedural; import artofillusion.math.*; import artofillusion.ui.*; import java.awt.*; public class AbsModule extends Module { private boolean signOk, positive; private double lastBlur; public AbsModule(Point position) { super(Translate.text("menu.absModule"), new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.LEFT, new String [] {"Input", "(0"})}, new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Output"})}, position); } /* New point, so the value will need to be recalculated. */ public void init(PointInfo p) { signOk = false; } /* Calculate the output value. */ public double getAverageValue(int which, double blur) { double value = (linkFrom[0] == null) ? 0.0 : linkFrom[0].getAverageValue(linkFromIndex[0], blur); positive = value > 0.0; signOk = true; lastBlur = blur; return positive ? value : -value; } /* The error is unchanged by this module. */ public double getValueError(int which, double blur) { return (linkFrom[0] == null) ? 0.0 : linkFrom[0].getValueError(linkFromIndex[0], blur); } /* Calculate the gradient. */ public void getValueGradient(int which, Vec3 grad, double blur) { if (!signOk || blur != lastBlur) getAverageValue(which, blur); linkFrom[0].getValueGradient(linkFromIndex[0], grad, blur); if (!positive) grad.scale(-1.0); } }

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.1897.438−62.615
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.5.028−7.543

Intercept 8.87 + feature contributions = -34.888 (log-odds).
Score = sigmoid(-34.888) = 0.

Score0.577

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.145−2.476
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.144.985+1.535
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.58+1.269
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.58−0.91
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.65.678+0.508
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.081+0.151

Intercept 0.07 + feature contributions = -1.19 (log-odds).
Score = sigmoid(-1.19) = 0.233.

Score0.46
Score19
Run 1

The code is well-structured with clear separation of methods, minimal nesting, and concise implementation. Each method has a single responsibility and the logic is straightforward. Comments explain the intent of each method effectively. The constructor signature is long but remains readable due to consistent formatting. Variable names like signOk, positive, and lastBlur clearly convey their purpose. Action granularity is appropriate—most lines perform one logical operation. The reading flow is natural: initialization, value calculation, error handling, and gradient computation follow a logical sequence. Minor deductions could apply to the slightly verbose constructor and the reliance on a cached state (signOk/lastBlur) which requires careful tracking, but overall readability is high.

Run 2

The code is well-structured and readable. It clearly separates concerns with distinct methods for initialization, average value calculation, error propagation, and gradient computation. Nesting is minimal, with only straightforward conditional checks. Intent is clear: the module computes absolute values, and comments explain each method's purpose. Code length is appropriate, neither overly verbose nor too terse. Action granularity is good, with one logical operation per line. Reading flow is natural, following the expected lifecycle of a procedural module (init → calculate → error → gradient). Minor issues: the constructor has a long line with a typo in the input label and no newline between a method and the following comment, slightly affecting formatting consistency. Overall, the code is highly maintainable and easy to understand.

Run 3

The code is generally well-structured and readable. It follows a clear logical organization with methods separated by purpose: initialization, value calculation, error propagation, and gradient computation. Nesting is minimal, with a single ternary expression and one conditional in getValueGradient. Intent is mostly clear, though the caching behavior (signOk, lastBlur) could benefit from a brief comment explaining the invalidation strategy. Code length is appropriate—each method is concise and focused. Action granularity is good: one logical action per line, with no dense multi-statement lines. Reading flow is natural, progressing from constructor to core computation to error handling. Minor deductions: the constructor call is quite long with deeply nested array initialization, which slightly hurts scanability. The field declarations lack explanatory comments, and the magic string "(0" appears unexplained. Overall, this is maintainable and readable procedural code.

Run 1

Code Structure: The class is logically organized into construction, initialization, value calculation, error propagation, and gradient calculation. Nesting: Control flow is flat, with simple conditionals and no nested blocks. Clarity of intent: The class name, method names, and comments clearly communicate absolute-value behavior, though signOk and positive require some interpretation of cached state. Code length: The implementation is concise; the lengthy license header is conventional rather than unnecessary implementation detail. Action granularity: Most lines perform one action, but the constructor packs several nested object and array constructions into long lines. Reading flow: Methods follow a natural sequence, with consistent indentation and useful comments. Wildcard imports, omitted conditional braces, and dense constructor formatting slightly hinder scanning. The gradient method's unconditional input dereference also makes disconnected-input behavior less clear than in the other methods.

Run 2

Code Structure: The class is logically organized into construction, initialization, value calculation, error propagation, and gradient calculation. Nesting: Methods remain flat, with only simple conditionals and ternary expressions. Clarity of intent: The class name and brief comments clearly communicate absolute-value behavior, though signOk and positive require some interpretation of cached state. Code length: The implementation is concise; the lengthy license header is conventional rather than unnecessary logic. Action granularity: Statements generally perform one action per line, although the constructor packs several nested object and array creations into long lines. Reading flow: Method ordering and straightforward calculations support natural reading. Dense constructor formatting, wildcard imports, omitted braces around conditionals, and the gradient method's implicit assumption that an input exists slightly reduce readability.

Run 3

Code Structure: Small, logically organized class with separate methods for initialization, value, error, and gradient calculation. Nesting: Very shallow, with simple conditionals and no nested control flow. Clarity of intent: The class name and method comments clearly describe absolute-value behavior, but signOk and positive require interpreting shared caching state. The gradient method's lack of a null check, unlike the other methods, makes input assumptions less clear. Code length: Implementation is concise; the lengthy constructor expressions are the main readability burden. Action granularity: Most statements perform one action per line, although combined field declarations and inline port construction compress details. Reading flow: Methods follow a natural progression, but long lines, wildcard imports, omitted conditional braces, and slightly inconsistent spacing reduce scanability.