2012/3/1, Anne Schilling <a...@math.ucdavis.edu>: > Now Mike pointed out further that whether an element needs to be typed or > not to be in the set > is rather arbitrary: > > sage: [3,1,2] in Compositions() > True > sage: [1,2,3,4] in Words() > False > sage: [1,0,1,0] in DyckWords() > True > sage: [[1,2],[3]] in Tableaux() > True > sage: [1,2,3,4] in LyndonWords() > True > sage: [[1,2,3],[4,5]] in SetPartitions(5) > True > sage: [1,2,3,4] in Permutations(4) > True
On that question, the default implementation in sage.parent.Parent.__contains___ is a bit curious: to test whether x is in P, it first does y = P(x). If it leads to a TypeError or ValueError then False is returned, otherwise, it returns the value of x == y. We definitely needs two methods for testing whether x is in P: 1) strong element checking: x should be an instance of Element and has parent P or has a Parent with a natural coercion to P (not valid for facade) 2) permissive type checking: returns True if P(x) is allowed We have to choose whether 'sage: x in P' does 1) or 2). The default Parent implementation is actually between them. Should a convention be adopted for all parents ? Only for parent in the Sets() category ? Cheers, Vincent -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.