difference between PermutationGroup.has_element and PermutationGroup.__contains__
43 views
Skip to first unread message
Martin R
unread,
May 9, 2022, 3:35:42 AM5/9/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-devel
I just found
{{{
def __contains__(self, item): """ Return whether ``item`` is an element of the group.
...
def has_element(self, item): """ Returns boolean value of ``item in self`` - however *ignores* parentage.
...
"""
return item in self
}}}
Isn't has_element just an alias of __contains__?
Martin
davida...@gmail.com
unread,
May 9, 2022, 2:17:09 PM5/9/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-devel
As you noticed, the difference between these two methods is very thin. The special method "__contains__" is necessary because it is called whenever the keyword "in" is used. I think that the code could have been simplified to:
{{{
def __contains__(self, item): """ Return whether ``item`` is an element of the group.
...
has_element = __contains__
}}}
Why wasn't it done like this before? I don't know. Is there a better practice? I don't know.
What I know is that if you implement a new structure following the Parent/Element framework (for example:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-devel
Exactly this is what I meant with "alias", and why I think that its documentation is misleading, if not wrong. I just checked, has_element is not used in the sage library at all. I thus propose to deprecate it.
Kwankyu Lee
unread,
May 10, 2022, 7:10:18 AM5/10/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-devel
On Tuesday, May 10, 2022 at 6:35:10 AM UTC+9 axio...@yahoo.de wrote:
Exactly this is what I meant with "alias", and why I think that its documentation is misleading, if not wrong. I just checked, has_element is not used in the sage library at all. I thus propose to deprecate it.
+1. But first survey use of `has_element` throughout sage library, to balance.
Martin R
unread,
May 10, 2022, 8:30:07 AM5/10/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message