Ticket #14541: 14541.patch

File 14541.patch, 1.5 KB (added by cnassau, 9 years ago)
  • sage/sets/family.py

    # HG changeset patch
    # User Christian Nassau <nassau@nullhomotopie.de>
    # Date 1367936373 -7200
    # Node ID cd6022356d8869abdb6e147b7129e8a9bedb36ef
    # Parent  b4db5e332c582a8b104cf14494d5aeda84295792
    #14541 - LazyFamily category detection if keys are a CombinatorialClass
    
    diff --git a/sage/sets/family.py b/sage/sets/family.py
    a b  
    828828            category = FiniteEnumeratedSets()
    829829        elif set in InfiniteEnumeratedSets():
    830830            category = InfiniteEnumeratedSets()
    831         elif isinstance(set, (list, tuple, CombinatorialClass)):
     831        elif isinstance(set, (list, tuple)):
    832832            category = FiniteEnumeratedSets()
     833        elif isinstance(set, CombinatorialClass):  # workaround for 14541
     834            if set.cardinality() < Infinity:
     835                category = FiniteEnumeratedSets()
     836            else:
     837                category = InfiniteEnumeratedSets()
    833838        else:
    834839            category = EnumeratedSets()
    835840
     
    922927            sage: l = LazyFamily(NonNegativeIntegers(), lambda i: 2*i)
    923928            sage: l.cardinality()
    924929            +Infinity
     930            sage: x = LazyFamily(CartesianProduct(Integers(),Integers()),lambda i: i)
     931            sage: x.cardinality()
     932            +Infinity
    925933            """
    926934        try:
    927935            return Integer(len(self.set))
    928         except (AttributeError, NotImplementedError):
     936        except (AttributeError, NotImplementedError, TypeError):
    929937            return self.set.cardinality()
    930938
    931939    def __iter__(self):