summaryrefslogtreecommitdiff
path: root/pint/testsuite/test_quantity.py
diff options
context:
space:
mode:
authorCD Clark III <clifton.clark@gmail.com>2022-05-05 22:02:52 -0500
committerCD Clark III <clifton.clark@gmail.com>2022-05-05 22:10:59 -0500
commitae8e91954a6160932629735ed75cab7c3727f9ac (patch)
tree315c6112473a6b504b0b801f36d24a71485d326e /pint/testsuite/test_quantity.py
parent1208759968b1178a189c9fc92df95034cc020798 (diff)
downloadpint-ae8e91954a6160932629735ed75cab7c3727f9ac.tar.gz
fix LaTeX siunitx exponent formatting (closes #1515)
With siunitx, you can format a quantity in scientfic notation by specifying the quantity's magnitude in 'e' notation. \SI{1e2}{\meter} Here, the '1e2' will expand to '1 \times 10^{2}'. So, when Pint formats exponents for LaTeX, it should *not* expand '1e2' to '1 \times 10^{2}' *if* siunitx is used. This commit adds a check to disable expaning exponents for quantity magnitude formatting if siunitx is used.
Diffstat (limited to 'pint/testsuite/test_quantity.py')
-rw-r--r--pint/testsuite/test_quantity.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/pint/testsuite/test_quantity.py b/pint/testsuite/test_quantity.py
index 196d0c3..7648d28 100644
--- a/pint/testsuite/test_quantity.py
+++ b/pint/testsuite/test_quantity.py
@@ -294,11 +294,13 @@ class TestQuantity(QuantityTestCase):
x = ureg.Quantity(1e20, "meter")
assert f"{x:~H}" == r"1×10<sup>20</sup> m"
assert f"{x:~L}" == r"1\times 10^{20}\ \mathrm{m}"
+ assert f"{x:~Lx}" == r"\SI[]{1e+20}{\meter}"
assert f"{x:~P}" == r"1×10²⁰ m"
x /= 1e40
assert f"{x:~H}" == r"1×10<sup>-20</sup> m"
assert f"{x:~L}" == r"1\times 10^{-20}\ \mathrm{m}"
+ assert f"{x:~Lx}" == r"\SI[]{1e-20}{\meter}"
assert f"{x:~P}" == r"1×10⁻²⁰ m"
def test_ipython(self):