maintenance: raw-string the LaTeX-carrying docstrings - #47
Merged
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".
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
\s,\l,\[— escapes Python does not recogniseSyntaxWarningper compile; slated to becomeSyntaxError\tin\theta,\fin\frac,\rin\rm13 literals across 4 files get the
rprefix. Both sweeps now return zero. Prose is untouched — only the delimiter gains anr.Verification
markdown/,llms-full.txtandworkspace_index.jsonare 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 theris 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