Skip to content

maintenance: raw-string the LaTeX-carrying docstrings - #47

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/latex-raw-string-docstrings-9h4ine
Aug 20, 2026
Merged

maintenance: raw-string the LaTeX-carrying docstrings#47
Jammy2211 merged 1 commit into
mainfrom
claude/latex-raw-string-docstrings-9h4ine

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

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.

Non-raw docstrings containing LaTeX are corrupted by Python's escape handling, in two classes — and only one of them is visible:

what it is diagnostic
warned \s, \l, \[ — escapes Python does not recognise SyntaxWarning per compile; slated to become SyntaxError
silent \t in \theta, \f in \frac, \r in \rm none at all — the value is simply corrupted

13 literals across 4 files get the r prefix. Both sweeps now return zero. Prose is untouched — only the delimiter gains an r.

Verification

  • Baseline regeneration is a no-op — the generator was run before editing and left the tree clean, so generator noise cannot fake the gate below.
  • Runtime values: 7 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. This is the check that catches real mistakes — the regeneration gate structurally cannot, because the generator reads source text, not runtime values.
  • Regenerated with autohands: markdown/, llms-full.txt and workspace_index.json are byte-identical.

One note on the notebook diff

Two notebooks change, and both are expected. The four plt.ylabel("Normalized Residuals ($\sigma$)") labels are runtime strings in code cells, not docstrings — code cells copy source verbatim, so the r is meant to show there. Every prose cell is unchanged. This is the only repo of the six with such a delta.

Left alone deliberately

print("\nInfo:") and friends keep their real newlines, and " \\[-2pt]" keeps its already-escaped LaTeX line break. 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 — before it, raw-stringing these files would have shipped tutorial prose as code cells.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MTjtx5mdituitiyQYFGn2E


Generated by Claude Code

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".

13 literals across 4 files get the `r` prefix. Both sweeps now return zero.

Verified, not assumed:
- Runtime values: 7 corruptions repaired, 0 other changes. Each changed
  literal's value was compared HEAD vs worktree; the prefix may only ever
  REMOVE corruption, never alter a string otherwise.
- Regenerated with autohands: markdown/, llms-full.txt and workspace_index.json
  are byte-identical. The only notebook delta is the four `plt.ylabel` labels,
  which are runtime strings in CODE cells, so the source change is meant to
  show there. Prose cells are unchanged.

Deliberate escapes were left alone: `print("\nInfo:")` and friends keep their
real newlines, and `" \\[-2pt]"` keeps its already-escaped LaTeX line break.
The prefix was only applied where every backslash sits in a LaTeX context
($...$, \(...\), \[...\], \begin{}...\end{}, or a markdown code span).
@Jammy2211
Jammy2211 merged commit f30f9ce into main Aug 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants