From 1471fb3b890c1dc3e4611e46281cd88a4f7f31c5 Mon Sep 17 00:00:00 2001 From: nstarman Date: Fri, 24 Jul 2026 11:24:23 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(unxts-linalg):=20cover=20Quant?= =?UTF-8?q?ityMatrix=20short=5Fname=20"QM"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror the Quantity/ParametricQuantity printing tests: assert `QuantityMatrix.short_name == "QM"`, that it renders its full class name by default, and that `use_short_name=True` renders `QM(...)`. Co-Authored-By: Claude Opus 4.8 --- packages/unxts.linalg/tests/test_printing.py | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/unxts.linalg/tests/test_printing.py diff --git a/packages/unxts.linalg/tests/test_printing.py b/packages/unxts.linalg/tests/test_printing.py new file mode 100644 index 00000000..1006014f --- /dev/null +++ b/packages/unxts.linalg/tests/test_printing.py @@ -0,0 +1,29 @@ +"""Tests for QuantityMatrix printing with wadler-lindig.""" + +import jax.numpy as jnp +import wadler_lindig as wl +from unxts.linalg import QM, QuantityMatrix + + +class TestQuantityMatrixShortName: + """Short-name / pretty-printing behavior specific to ``QuantityMatrix``.""" + + def test_quantitymatrix_short_name(self): + """``QuantityMatrix`` (``QM``) has short_name 'QM'.""" + assert hasattr(QuantityMatrix, "short_name") + assert QuantityMatrix.short_name == "QM" + assert QM.short_name == "QM" + + def test_uses_full_name_by_default(self): + """``QuantityMatrix`` uses its full name by default.""" + qv = QuantityMatrix(jnp.array([1.0, 2.0, 3.0]), unit=("m", "s", "kg")) + result = wl.pformat(qv) + assert result.startswith("QuantityMatrix") + assert not result.startswith("QM(") + + def test_use_short_name_true(self): + """``QuantityMatrix`` uses its short name 'QM'.""" + qv = QuantityMatrix(jnp.array([1.0, 2.0, 3.0]), unit=("m", "s", "kg")) + result = wl.pformat(qv, use_short_name=True) + assert result.startswith("QM(") + assert "unit='(m, s, kg)'" in result