Coverage for src/hypra/hpl/named_constants.py: 100.00%
24 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-26 22:12 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-26 22:12 +0000
1"""Named HPL 2 constants from weakly ordered signed harmonic sums."""
3import sympy as s
5from ..symbolic import EulerSum
6from .alternating import reduce_euler_sum
9def _weak_sum(word: tuple[int, ...]) -> s.Expr:
10 # Partition the weakly ordered simplex into strict blocks of equal indices.
11 # A merged block adds exponents and multiplies colors.
12 first, *rest = word
13 partitions = [((abs(first), 1 if first > 0 else -1),)]
14 for index in rest:
15 power, color = abs(index), 1 if index > 0 else -1
16 partitions = [
17 block
18 for prefix in partitions
19 for block in (
20 (*prefix, (power, color)),
21 (*prefix[:-1], (prefix[-1][0] + power, prefix[-1][1] * color)),
22 )
23 ]
24 return reduce_euler_sum(
25 s.Add(*(EulerSum(*zip(*partition, strict=True)) for partition in partitions))
26 )
29HPLs6: s.Expr = _weak_sum((-5, -1))
30"""Weight-six weak sum with signed indices (-5, -1)."""
32# These signs follow the executable numerical definitions and their values.
33# The package's usage strings print different final signs for these two.
34HPLs7a: s.Expr = _weak_sum((-5, 1, 1))
35"""Weight-seven weak sum with signed indices (-5, 1, 1)."""
37HPLs7b: s.Expr = _weak_sum((5, -1, -1))
38"""Weight-seven weak sum with signed indices (5, -1, -1)."""
40HPLs8a: s.Expr = _weak_sum((5, 3))
41"""Weight-eight weak sum with indices (5, 3)."""
43HPLs8b: s.Expr = _weak_sum((-7, -1))
44"""Weight-eight weak sum with signed indices (-7, -1)."""
46HPLs8c: s.Expr = _weak_sum((-5, -1, -1, -1))
47"""Weight-eight weak sum with signed indices (-5, -1, -1, -1)."""
49HPLs8d: s.Expr = _weak_sum((-5, -1, 1, 1))
50"""Weight-eight weak sum with signed indices (-5, -1, 1, 1)."""