maintenance: raw-string the LaTeX-carrying docstrings - #73
Conversation
Non-raw docstrings containing LaTeX are corrupted by Python's escape handling.
Two distinct failure classes, and only the first is visible:
warned `\s`, `\l`, `\[` ... escapes Python does NOT recognise. It leaves
them literal but emits SyntaxWarning on every compile/import, and
they are slated to become a SyntaxError.
silent `\t` in `\theta`, `\f` in `\frac`, `\r` in `\rm`, `\b` in `\beta`.
Escapes Python DOES recognise: the value is corrupted with NO
diagnostic at all. `\theta_E` was literally TAB + "heta_E".
32 literals across 8 files get the `r` prefix. Both sweeps now return zero.
Verified, not assumed:
- Runtime values: 21 corruptions repaired, 0 other changes. Every changed
literal's value was compared HEAD vs worktree; the prefix may only ever
REMOVE corruption, never alter a string otherwise.
- Regenerated with autohands: notebooks/, markdown/, llms-full.txt and workspace_index.json are ALL byte-identical -- the diff-empty gate passes exactly.
This repo carries the defect the original prompt was filed on:
chapter_4 tutorial_3_scaling_relation.py had `\theta_E` stored as TAB + "heta_E".
Confirmed repaired -- the docstring value now holds a real backslash and no TAB.
chapter_4 tutorial_5_cluster_scale.py has ONLY silent hits and zero warnings, so
a warning-only sweep would have skipped it entirely; it is included here.
Prose is untouched -- only the delimiter gains an `r`. Deliberate escapes were
left alone (real newlines in print(), already-escaped LaTeX line breaks): the
prefix was applied only where every backslash sits in a LaTeX context.
|
Smoke is red on this PR, but the failure is on Two scripts fail with numba Evidence it isn't this PR:
Likely cause, not proven: PyAutoLabs/PyAutoArray#453 ("in-place Cholesky buffer + copy-free numba solves for I tested two specific mechanisms under the exact CI versions (numba 0.67.0 + scipy 1.17.1) and both passed — a strided This PR's own verification is unaffected: 21 corruptions repaired with 0 unexpected value changes, and Generated by Claude Code |
Part of PyAutoLabs/autolens_workspace#491 — one of six independent, prose-only PRs (one per workspace repo). No API surface, so no cross-repo merge ordering.
This repo carries the defect the whole task was filed on. In
chapter_4_scaling_up_lensing/tutorial_3_scaling_relation.py,\theta_Ewas stored asTAB+"heta_E"— a silent corruption with no diagnostic whatsoever. Confirmed repaired: the docstring value now holds a real backslash and contains no TAB.\s,\l,\[— escapes Python does not recogniseSyntaxWarningper compile; slated to becomeSyntaxError\tin\theta,\fin\frac,\rin\rmchapter_4_scaling_up_lensing/tutorial_5_cluster_scale.pyhas only silent hits and zero warnings, so a warning-only sweep skips it entirely. It is included here.32 literals across 8 files get the
rprefix. Both sweeps now return zero. Prose is untouched — only the delimiter gains anr.Verification
notebooks/,markdown/,llms-full.txtandworkspace_index.jsonare all byte-identical — the diff-empty gate passes exactly.Two docstrings needed a hand-approved prefix, both read in full first:
chapter_2_lens_modeling/tutorial_1_non_linear_search.pyhas pre-existing malformed nested LaTeX the math-span matcher cannot bracket, andtutorial_3_scaling_relation.pywrites bare\sigma/\theta_E/\piin undelimited equation blocks. Neither carries a deliberate escape. Malformed delimiters were left exactly as found.Left alone deliberately
Real newlines in
print()and already-escaped LaTeX line breaks. The prefix was applied only where every backslash in the literal sits in a LaTeX context ($…$,\(…\),\[…\],\begin{}…\end{}, or a markdown code span), with an absolute veto on\\, escaped quotes and numeric escapes regardless of context.Unblocked by PyAutoHands#251, which taught the notebook and env parsers to accept an
r"""opener.🤖 Generated with Claude Code
https://claude.ai/code/session_01MTjtx5mdituitiyQYFGn2E
Generated by Claude Code