Skip to content

Explorer uncertainty and strict lint - #28

Merged
SebastianAment merged 2 commits into
mainfrom
explorer-uncertainty-and-strict-lint
Jun 9, 2026
Merged

Explorer uncertainty and strict lint#28
SebastianAment merged 2 commits into
mainfrom
explorer-uncertainty-and-strict-lint

Conversation

@SebastianAment

@SebastianAment SebastianAment commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Explorer uncertainty consistency + strict-lint hardening

Two cleanups following the V2 strength GP open-source PR.

1. Consistent ±2σ uncertainty in the explorer (f974a55)

The strength-curve plot has always shaded mean ± 2σ, but the cost readout displayed ± 1σ — same ± symbol, two different conventions in the same view.

  • docs/ui.mjs::updateUI — cost readout now reads ± {2σ value} (2σ).
  • docs/ui.mjs::drawStrengthCurve — adds a small on-canvas shaded: ±2σ legend in the plot's top-right corner.
  • About-modal text already documented ±2σ for the band — kept as-is, now consistent end-to-end.

2. Strict-lint hardening + dev-onboarding (3a7e82f)

CI's flake8 strict-select now covers the full set of bug-detector and key style codes (matching BoTorch/GPyTorch's 88-char convention):

Code What it catches
E9, F63, F7, F82 syntax errors, undefined names
F401, F811, F841 unused imports / redefinitions / unused locals
E202 whitespace before }
E226 missing whitespace around arithmetic operator
E251 unexpected spaces around keyword/parameter equals
E402 module-level import not at top of file
E501 line too long (88 chars)
E741 ambiguous variable name (I / l / O)

Files modified to conform

  • boxcrete/slump_model.py — drop unused import torch.
  • docs/generate_mix_analyses.py — drop unused cost/str_1 locals; wrap ~20 long f-strings.
  • test/test_partial_fixed_noise_likelihood.py — drop unused n_total.
  • boxcrete/features.py — move from boxcrete.utils import DEFAULT_X_COLUMNS to top of module (E402); wrap 3 long lambda-builder lines.
  • experiments/regenerate_strength_json.py — relocate # noqa: E402 to opening line of multi-line import; wrap 2 long print lines.
  • boxcrete/plotting.py:191 + test/test_models.py:412 — rename I = torch.eye(...)eye_n (E741: linear-algebra I clashes with 1/l).
  • boxcrete/utils.py — f-string {x = }{x=} (E202/E251); wrap 5 long docstring/error lines.
  • experiments/check_artifacts_drift.py*100* 100 (E226).
  • test/test_lengthscale_identifiability.py*100* 100 (E226).
  • boxcrete/concrete_model.py — wrap 5 long docstring/error lines.
  • boxcrete/kernels.py — wrap a 196-char inline pragma: no cover comment.
  • boxcrete/likelihoods.py — wrap 4 long pragma: no cover lines.
  • boxcrete/slump_model.py — wrap 1 long module-docstring line.
  • test/test_strength_curve_monotonicity.py — wrap 3 long error-message lines.
  • test/test_models.py:220, test/test_utils.py:679 — tighten 2 long docstrings.

Bonus fix in .flake8

The explicit exclude list (build, dist, .eggs) silently overrode flake8's defaults, so .git, __pycache__, .hg, etc. were being linted. Sapling stores backup copies of working-tree files under .git/sl/origbackups/ — without explicit re-add of the default excludes, flake8 reported 26 phantom violations from old deleted research code. Defaults restored explicitly.

Developer ergonomics

  • .pre-commit-config.yaml synced to match CI's strict-select. "Green locally" now implies "green CI" — no more surprises after pushing.

  • README.md new ## Development section explaining one-time setup:

    pip install -e ".[dev]"
    pre-commit install

Both the strength-curve shaded band and the cost readout now display
posterior uncertainty at ±2σ (~95% credible interval). Previously the
band was ±2σ but the cost readout was ±1σ — the same ± symbol meant
two different things in the same view, an avoidable cognitive hazard.

Changes:
  * docs/ui.mjs::updateUI cost readout: format as
    '± {(2 * costStd).toFixed(1)} (2σ)' so the explicit '(2σ)' suffix
    tells users which confidence band they're seeing.
  * docs/ui.mjs::drawStrengthCurve: add an on-canvas legend
    'shaded: ±2σ' in the top-right corner of the strength-curve plot
    so users don't need to open the About modal to know what the
    shaded band represents.
  * The existing About-modal text (docs/index.html:141) already
    documents ±2σ for shaded bands — kept as-is, now consistent with
    both the canvas legend and the readout.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 9, 2026
@SebastianAment
SebastianAment force-pushed the explorer-uncertainty-and-strict-lint branch 2 times, most recently from 154c3ed to 3a7e82f Compare June 9, 2026 19:57
…ev-onboarding

Adds the full E-class style codes plus the pyflakes bug-detectors to
the CI strict-select list so they fail the build instead of merely
warning. Local pre-commit config now mirrors CI, so 'green locally'
implies 'green CI'. Plus README onboarding for new contributors.

Strict-select gates now include:
  * E9 / F63 / F7 / F82  syntax errors, undefined names
  * F401 / F811 / F841   unused imports / redefinitions / unused locals
  * E202                  whitespace before '}'
  * E226                  missing whitespace around arithmetic operator
  * E251                  unexpected spaces around keyword/parameter equals
  * E402                  module-level import not at top of file
  * E501                  line too long (88-char limit, matches BoTorch)
  * E741                  ambiguous variable name ('I'/'l'/'O')

Files modified to conform:
  * boxcrete/slump_model.py         drop unused 'import torch'
  * docs/generate_mix_analyses.py   drop unused 'cost'/'str_1' locals;
                                    wrap ~20 long f-strings
  * test/test_partial_fixed_noise_likelihood.py  drop unused 'n_total'
  * boxcrete/features.py            move 'from boxcrete.utils import
                                    DEFAULT_X_COLUMNS' to top of module
  * experiments/regenerate_strength_json.py  relocate '# noqa: E402'
                                    to opening line of multi-line import
  * boxcrete/plotting.py:191        rename 'I' -> 'eye_n' (E741)
  * test/test_models.py:412         rename 'I' -> 'eye_n' (E741)
  * boxcrete/utils.py:275-276,467   f-string '{x = }' -> '{x=}' (E202/E251)
  * experiments/check_artifacts_drift.py  '*100' -> '* 100' (E226)
  * test/test_lengthscale_identifiability.py  '*100' -> '* 100' (E226)
  * boxcrete/concrete_model.py      wrap 5 long docstring/error lines
  * boxcrete/kernels.py             wrap 196-char inline comment
  * boxcrete/likelihoods.py         wrap 4 long pragma-comment lines
  * boxcrete/utils.py               wrap 5 long docstring/error lines
  * boxcrete/slump_model.py         wrap 1 long module-docstring line
  * docs/generate_mix_analyses.py   wrap 1 long obs-str line
  * experiments/regenerate_strength_json.py  wrap 2 long print lines
  * test/test_models.py:220         tighten long docstring
  * test/test_strength_curve_monotonicity.py  wrap 3 long error-msg lines
  * test/test_utils.py:679          tighten long docstring

Bonus fix in .flake8: explicit 'exclude' list was silently overriding
flake8's defaults, so .git, __pycache__, .hg, etc. were being linted.
Sapling stores backup copies of working-tree files under
.git/sl/origbackups/ — without the explicit re-add of the default
excludes, flake8 was reporting violations from old deleted research
code. Defaults restored explicitly.

Developer ergonomics:
  * .pre-commit-config.yaml synced to the CI strict-select so the
    local pre-commit hook fails on the same codes CI does (no more
    'green locally, red on CI' surprises).
  * README adds a 'Development' section explaining
    'pip install -e ".[dev]" && pre-commit install' onboarding, the
    role of black (auto-fix) vs flake8 (gate), and the 88-char line
    convention (matches BoTorch/GPyTorch).
@SebastianAment
SebastianAment force-pushed the explorer-uncertainty-and-strict-lint branch from 3a7e82f to e8403c8 Compare June 9, 2026 20:15
@SebastianAment
SebastianAment merged commit 3d544a7 into main Jun 9, 2026
19 of 20 checks passed
@SebastianAment
SebastianAment deleted the explorer-uncertainty-and-strict-lint branch June 9, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant