Latest Results
🐛 fix(quantity): stop `_repr_latex_` corrupting units without `_repr_latex_` (#870)
`_repr_latex_` sliced `[1:-1]` off the unit's representation, assuming
astropy's `$...$` wrapping. A unit type without `_repr_latex_` falls back to
plain `repr`, which carries no such wrapping, so the slice ate real
characters instead:
before: '$[1.,~2.,~3.] \; nitsMatrix("(m, s, kg)"$'
after: '$[1.,~2.,~3.] \; UnitsMatrix("(m, s, kg)")$'
`unxts.linalg.QuantityMatrix` hits this, since its unit is a `UnitsMatrix`.
Nothing covered it.
Strip the delimiters only when they are actually present, rather than keying
off whether the unit implements `_repr_latex_` at all -- that proxy reproduces
the same defect one step removed, mangling `r"\mathrm{m}"` into `"mathrm{m"`
for any implementation that returns an unwrapped string. The length guard is
load-bearing too: a lone `"$"` satisfies both `startswith` and `endswith` and
would otherwise be sliced away entirely.
Five cases pinned: the `QuantityMatrix` regression, plus four exercising the
mixin directly, since no real unit type takes the unwrapped branch -- wrapped
LaTeX unwrapped exactly once, unwrapped LaTeX left intact, no `_repr_latex_`
falling back to `repr`, and a lone `$` surviving.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Latest Branches
-11%
nstarman:claude/unit-systems-plum-d66f71 -19%
nstarman:quantity-parametric-rename +20%
nstarman:tests/fix-benchmarks © 2026 CodSpeed Technology