Skip to content

Commit

Permalink
Trac #33831: deprecate unused PermutationGroup_generic.has_element
Browse files Browse the repository at this point in the history
The method `PermutationGroup_generic.has_element` is unused and
`G.has_element(g)` is the same as `g in G`.  It should therefore be
deprecated.

URL: https://trac.sagemath.org/33831
Reported by: mantepse
Ticket author(s): Martin Rubey
Reviewer(s): David Ayotte
  • Loading branch information
Release Manager committed May 22, 2022
2 parents c4f35cf + 1a13f63 commit 2bb3b14
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,13 @@ def __contains__(self, item):
sage: G = PermutationGroup([[('a','b')]], domain=('a', 'b'))
sage: [('a', 'b')] in G
True
sage: G = CyclicPermutationGroup(4)
sage: H = DihedralGroup(4)
sage: g = G([(1,2,3,4)]); g
(1,2,3,4)
sage: g in H
True
"""
try:
self._element_constructor_(item)
Expand All @@ -1068,12 +1075,18 @@ def has_element(self, item):
sage: g = G([(1,2,3,4)]); g
(1,2,3,4)
sage: G.has_element(g)
doctest:warning
...
DeprecationWarning: G.has_element(g) is deprecated; use :meth:`__contains__`, i.e., `g in G` instead
See https://trac.sagemath.org/33831 for details.
True
sage: h = H([(1,2),(3,4)]); h
(1,2)(3,4)
sage: G.has_element(h)
False
"""
from sage.misc.superseded import deprecation
deprecation(33831, "G.has_element(g) is deprecated; use :meth:`__contains__`, i.e., `g in G` instead")
return item in self

def __iter__(self):
Expand Down

0 comments on commit 2bb3b14

Please sign in to comment.