Skip to content

Commit c033a15

Browse files
committed
Merge main
2 parents 1638ab8 + d378c26 commit c033a15

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

lips/algebraic_geometry/covariant_ideal.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import re
22
import numpy
33
import sympy
4+
import functools
5+
6+
from collections import defaultdict
47

58
from lips.tools import flatten
69
from lips.algebraic_geometry.tools import lips_covariant_symbols, lips_invariant_symbols, conversionIdeal
@@ -30,7 +33,7 @@ def __init__(self, ring_or_multiplicity, generators_or_covariants, momentum_cons
3033
oParticles.make_analytical_d()
3134
generators = []
3235
for covariant in generators_or_covariants:
33-
poly_or_polys = 4 * oParticles(covariant)
36+
poly_or_polys = 4 * oParticles(covariant) # TODO: remove 4 * when https://github.com/sympy/sympy/pull/28139 is accepted
3437
if hasattr(poly_or_polys, 'shape'):
3538
polys = flatten(poly_or_polys)
3639
for poly in polys:
@@ -57,7 +60,7 @@ def __contains__(self, covariant):
5760
oParticles = Particles(self.multiplicity)
5861
oParticles.make_analytical_d()
5962
try:
60-
poly_or_polys = 4 * oParticles(covariant)
63+
poly_or_polys = 4 * oParticles(covariant) # TODO: remove 4 * when https://github.com/sympy/sympy/pull/28139 is accepted
6164
except TypeError:
6265
poly_or_polys = covariant
6366
if isinstance(poly_or_polys, numpy.ndarray):
@@ -76,6 +79,16 @@ def image(self, rule):
7679
newIdeal.rule = rule
7780
return newIdeal
7881

82+
@functools.cached_property
83+
def equivalenceClass(self):
84+
from ..symmetries import all_symmetries
85+
all_perms_self = {symmetry: self(*symmetry) for symmetry in all_symmetries(self.multiplicity)}
86+
value_to_keys = defaultdict(list)
87+
for k, v in all_perms_self.items():
88+
value_to_keys[v].append(k)
89+
distinct_perms_self = {keys[0]: val for val, keys in value_to_keys.items()}
90+
return distinct_perms_self
91+
7992
def to_mom_cons_qring(self):
8093
oZeroIdeal = LipsIdeal(self.multiplicity, ())
8194
self.to_qring(oZeroIdeal)

lips/particle.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def __init__(self, kinematics=None, real_momentum=False, field=Field('mpc', 0, 3
5151
else:
5252
raise Exception('Bad Particle Constructor')
5353

54+
def to_field(self, field):
55+
self._r_sp_d = numpy.vectorize(field)(self.r_sp_d)
56+
self._r_sp_d_to_r_sp_u()
57+
self.l_sp_d = numpy.vectorize(field)(self.l_sp_d)
58+
self.field = field
59+
5460
def __eq__(self, other):
5561
"""Equality: checks equality of four momenta."""
5662
if isinstance(other, Particle):

lips/particles.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def __init__(self, number_of_particles_or_particles=None, seed=None, real_moment
7373
else:
7474
raise Exception(f"Internal masses not understood, received {internal_masses} of type {type(internal_masses)}.")
7575

76+
def to_field(self, field):
77+
for oP in self:
78+
oP.to_field(field)
79+
self.field = field
80+
7681
def __setattr__(self, name, value):
7782
if pMVar.match(name):
7883
self.internal_masses.add(name)

lips/symmetries.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ def inverse(permutation_or_symmetry):
2929

3030
def identity(n):
3131
return (''.join(str(i) for i in range(1, n + 1)), False)
32+
33+
34+
def all_symmetries(multiplicity):
35+
return phase_weights_compatible_symmetries([0] * multiplicity)

tests/test_particles.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,13 @@ def test_hashes_does_not_change_under_identity_mapping():
151151
# cache_key_hash2 = hashlib.sha256(cache_key_bytes).hexdigest()
152152
assert hash(oPs) == hash(oPsMapped)
153153
# assert cache_key_hash1 == cache_key_hash2 # this fails and I'm unsure how to fix it atm
154+
155+
156+
def test_field_change():
157+
Fp = Field("finite field", 2 ** 31 - 1, 1)
158+
oPsFp = Particles(6, field=Field("rational", 0, 0), seed=0)
159+
oPsFp.to_field(Fp)
160+
Qp = Field("padic", 2 ** 31 - 1, 4)
161+
oPsQp = Particles(6, field=Field("rational", 0, 0), seed=0)
162+
oPsQp.to_field(Qp)
163+
assert oPsFp("⟨1|2⟩") == oPsQp("⟨1|2⟩").as_tuple[0]

0 commit comments

Comments
 (0)