Hi!
I sent a fix to issue #7805 which is about forcing the method _contains of an Interval to return False when the element is a Set (currently it's throwing an exception).
My fix is just a check on the type of other in that method - if it's a set, I return False.
I was thinking, could we add for all the classes that inherit from Set a list of types that can be contained?
For Interval, I would have to add in the __new__ method:
self.containedTypes = [float, int] #and possibly other numerical types.
Then, I could change my _contains method for any class implementing Set in the following way:
def _contains(self, other):
if type(other) is not Symbol and not any(map(lambda t: isinstance(other, t), self.containedTypes)):
return False
#do the actual calculations to see if other is contained, which will depend on the class we are implementing
That way, I automatically ensure that other will be of the types contained by my Set, and I would be able to extend that to more complicated sets (say, a set of sets...).
Let me know what you think!
Sam