Skip to content

fix: render index slot suffixes as a comma subscript - #213

Merged
oameye merged 1 commit into
mainfrom
fix/index-latex-double-subscript
Jul 16, 2026
Merged

fix: render index slot suffixes as a comma subscript#213
oameye merged 1 commit into
mainfrom
fix/index-latex-double-subscript

Conversation

@oameye

@oameye oameye commented Jul 16, 2026

Copy link
Copy Markdown
Member

Problem

An index accumulates numeric per-slot suffixes as the pipeline transforms it, via (i::Index)(k) (which does Symbol(name, "_", k)). For example an index reaches i_2_1 when completion mints a second distinct atom i(2) (i_2, slot 2) and scale later collapses it to its position-1 representative (i_2)(1) (i_2_1, slot 1).

_latex_index_suffix emitted the name verbatim as _{i_2_1}. The unbraced _2_1 is a double subscript, which MathJax rejects with "Double subscripts: use braces to clarify", so the entire equation was left unrendered (raw LaTeX source) in Documenter pages and notebooks.

Surfaced by the QuantumCumulants superradiant_laser_indexed example (corr_sc.eqs), while investigating QuantumCumulants PR #317.

Fix

The suffixes are slot numbers, so join them into a single comma subscript: i_2_1 renders as i_{2,1}. Bare index names (:i, :j) have no suffix and are unchanged.

The accumulated _2 part is load-bearing (it distinguishes the second-atom representative from the first, so two-atom moments do not fold into same-atom ones), so the name itself is preserved; only its rendering changes.

Tests

Added a regression testset in test/printing/printing_test.jl pinning i_{2,1} and confirming bare names are untouched. All 133 rendering tests pass.

Verified the transformed output renders in both MathJax v2 and v3.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.52%. Comparing base (e7e7648) to head (4077d66).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #213   +/-   ##
=======================================
  Coverage   94.51%   94.52%           
=======================================
  Files          27       27           
  Lines        2937     2939    +2     
=======================================
+ Hits         2776     2778    +2     
  Misses        161      161           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Results

Details
Benchmark suite Current: 4077d66 Previous: e7e7648 Ratio
Accumulation/Many-mode H/foldl M=16 11041 ns 10980 ns 1.01
Accumulation/Many-mode H/foldl M=24 24586 ns 24876 ns 0.99
Accumulation/Many-mode H/foldl M=8 2765.1111111111113 ns 2800.777777777778 ns 0.99
Accumulation/Many-mode H/sum M=16 1718.2 ns 1697.1 ns 1.01
Accumulation/Many-mode H/sum M=24 2294.222222222222 ns 2305.4444444444443 ns 1.00
Accumulation/Many-mode H/sum M=8 695.4850746268656 ns 729.7297297297297 ns 0.95
Accumulation/Same-site/foldl 6205.6 ns 6275.6 ns 0.99
Accumulation/Same-site/sum 2346.5555555555557 ns 2295.3333333333335 ns 1.02
Commutator/Nested JC/depth=1 1671.1 ns 1705.1 ns 0.98
Commutator/Nested JC/depth=2 18285 ns 17583 ns 1.04
Commutator/Nested JC/depth=3 66674 ns 66503 ns 1.00
Commutator/Nested JC/depth=4 170669 ns 168372 ns 1.01
Commutator/Nested JC/depth=5 378527 ns 372361 ns 1.02
Commutator/Schrieffer-Wolff/[S, V] 196577 ns 198388 ns 0.99
Commutator/Schrieffer-Wolff/[S, [S, H0]] 359101 ns 367321 ns 0.98
Indexing/Diagonal collapse/[H_Dicke, S_j] 43261 ns 44253 ns 0.98
Indexing/Diagonal collapse/[H_JC, σ_j] 62326 ns 63227 ns 0.99
Indexing/Simplify/double-sum spin-spin 16641 ns 16551 ns 1.01
Indexing/Simplify/indexed JC H 1150.2 ns 1169.1 ns 0.98
Indexing/Sum construction/double Σ_ij(J_ij*S_i*S_j) 8512.333333333334 ns 8766 ns 0.97
Indexing/Sum construction/single Σ_i(σ_i*σ_j) 11552 ns 10669 ns 1.08
Normal Order/Fock (c*c')^n/n=2 621.9545454545455 ns 611.7403314917127 ns 1.02
Normal Order/Fock (c*c')^n/n=3 894.2033898305085 ns 892.1754385964912 ns 1.00
Normal Order/Fock (c*c')^n/n=4 1198.2 ns 1183.2 ns 1.01
Normal Order/Fock (c*c')^n/n=5 1597.9 ns 1565.9 ns 1.02
Normal Order/Ground state/3-level rewrite 840.8 ns 809.5487804878048 ns 1.04
Normal Order/Multi-mode/2-mode 6-op chain 978.8 ns 964.421052631579 ns 1.01
Simplify/Jaynes-Cummings/H 1078 ns 1050 ns 1.03
Simplify/Jaynes-Cummings/H² 2431.222222222222 ns 2412.3333333333335 ns 1.01
Simplify/Two cavities/H 1113.1 ns 1103 ns 1.01
Simplify/Two cavities/H² 4497 ns 4495.428571428572 ns 1.00
Simplify/Λ-system/H 1343.5 ns 1352.5 ns 0.99
Simplify/Λ-system/H² 2284.222222222222 ns 2276.4444444444443 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

An index accumulates numeric per-slot suffixes as the pipeline transforms
it, via `(i::Index)(k)` (e.g. `i` -> `i_2` -> `i_2_1` when a second distinct
atom is later collapsed to its position-1 representative). `_latex_index_suffix`
emitted the name verbatim as `_{i_2_1}`, whose unbraced `_2_1` is a double
subscript that MathJax rejects ("Double subscripts: use braces to clarify"),
leaving whole equations unrendered in Documenter pages and notebooks.

Join the slot numbers into a single comma subscript instead (`i_2_1` renders
as `i_{2,1}`); bare index names are unchanged. Add a regression test.

Bump version to 0.9.5.
@oameye
oameye force-pushed the fix/index-latex-double-subscript branch from f09083a to 4077d66 Compare July 16, 2026 14:30
@oameye
oameye merged commit 6e26e93 into main Jul 16, 2026
13 checks passed
@oameye
oameye deleted the fix/index-latex-double-subscript branch July 16, 2026 16:05
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.

1 participant