Skip to content

Commit d83f90c

Browse files
author
Release Manager
committed
gh-38395: get rid of some sage-eval in gap3-related code this simplifies the gap3-parsing done in `_gap_return` and then get rid of ` sage_eval` used on top of that. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: #38395 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents f369f65 + a4aab67 commit d83f90c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/sage/combinat/root_system/reflection_group_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ def conjugacy_classes_representatives(self):
971971
"""
972972
# This can be converted to usual GAP
973973
S = str(gap3('List(ConjugacyClasses(%s),Representative)' % self._gap_group._name))
974-
return sage_eval(_gap_return(S), {'self': self})
974+
return [self(w, check=False) for w in _gap_return(S)]
975975

976976
def conjugacy_classes(self):
977977
r"""

src/sage/combinat/root_system/reflection_group_element.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ AUTHORS:
2121
# (at your option) any later version.
2222
# https://www.gnu.org/licenses/
2323
# ***************************************************************************
24+
import re
2425

2526
from sage.misc.lazy_attribute import lazy_attribute
2627
from sage.misc.misc_c import prod
@@ -31,6 +32,8 @@ from sage.combinat.root_system.reflection_group_c import reduced_word_c, reduce_
3132
from sage.matrix.constructor import Matrix
3233
from sage.matrix.special import identity_matrix
3334

35+
TUPLE = re.compile(r'(?:\([0-9,]*\))+')
36+
3437

3538
cdef class ComplexReflectionGroupElement(PermutationGroupElement):
3639
"""
@@ -1246,8 +1249,7 @@ def _gap_return(S, coerce_obj='self'):
12461249
12471250
sage: from sage.combinat.root_system.reflection_group_complex import _gap_return
12481251
sage: _gap_return("[ (), (1,4)(2,3)(5,6), (1,6,2)(3,5,4) ]") # optional - gap3
1249-
"[self('()',check=False),self('(1,4)(2,3)(5,6)',check=False),self('(1,6,2)(3,5,4)',check=False)]"
1252+
['()', '(1,4)(2,3)(5,6)', '(1,6,2)(3,5,4)']
12501253
"""
12511254
S = S.replace(' ', '').replace('\n', '')
1252-
S = S.replace(',(', '\',check=False),%s(\'(' % coerce_obj).replace('[', '[%s(\'' % coerce_obj).replace(']', '\',check=False)]')
1253-
return S
1255+
return TUPLE.findall(S)

src/sage/combinat/root_system/reflection_group_real.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747

4848
from sage.misc.cachefunc import cached_function, cached_method, cached_in_parent_method
4949
from sage.combinat.root_system.cartan_type import CartanType, CartanType_abstract
50+
from sage.interfaces.gap3 import gap3
5051
from sage.rings.integer_ring import ZZ
5152
from sage.combinat.root_system.reflection_group_complex import ComplexReflectionGroup, IrreducibleComplexReflectionGroup
52-
from sage.misc.sage_eval import sage_eval
5353
from sage.combinat.root_system.reflection_group_element import RealReflectionGroupElement
5454

5555

@@ -695,7 +695,7 @@ def right_coset_representatives(self, J):
695695
from sage.combinat.root_system.reflection_group_element import _gap_return
696696
J_inv = [self._index_set_inverse[j] + 1 for j in J]
697697
S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (self._gap_group._name, self._gap_group._name, J_inv)))
698-
return sage_eval(_gap_return(S), locals={'self': self})
698+
return [self(w, check=False) for w in _gap_return(S)]
699699

700700
def simple_root_index(self, i):
701701
r"""
@@ -820,8 +820,7 @@ def right_coset_representatives(self):
820820
if self.fix_space().is_subspace(T[i].fix_space())]
821821
S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (W._gap_group._name, W._gap_group._name, T_fix)))
822822
from sage.combinat.root_system.reflection_group_element import _gap_return
823-
return sage_eval(_gap_return(S, coerce_obj='W'),
824-
locals={'self': self, 'W': W})
823+
return [W(w, check=False) for w in _gap_return(S)]
825824

826825
def left_coset_representatives(self):
827826
r"""

0 commit comments

Comments
 (0)