Ticket #3738: 3738-fix-1.patch

File 3738-fix-1.patch, 3.5 KB (added by robertwb, 11 years ago)
  • sage/categories/map.pyx

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1218001908 25200
    # Node ID 799910270fc30be99a31c9831462b7b6e6562a7d
    # Parent  808aa5d3d7aaf1bf832b6bb9346ecd40ec5eecb3
    Fix doctests.
    
    Reverted parent.__len__ back to its original form.
    
    diff -r 808aa5d3d7aa -r 799910270fc3 sage/categories/map.pyx
    a b cdef class Map(Element): 
    252252    def is_surjective(self):
    253253        raise NotImplementedError, type(self)
    254254
    255     def __pow__(self, n, dummy):
    256         if not self._domain is not self._codomain:
     255    def __pow__(Map self, n, dummy):
     256        if self._domain is not self._codomain:
    257257            raise TypeError, "self must be an endomorphism."
    258258        # todo -- what about the case n=0 -- need to specify the identity map somehow.
    259259        return generic_power(self, n)
  • sage/rings/finite_field_morphism.py

    diff -r 808aa5d3d7aa -r 799910270fc3 sage/rings/finite_field_morphism.py
    a b class FiniteFieldHomset(RingHomset_gener 
    159159              To:   Finite Field in b of size 2^10
    160160              Defn: a |--> b^7 + b^5
    161161            sage: H[2:4]
    162             [Ring morphism:
     162            [
     163            Ring morphism:
    163164              From: Finite Field in a of size 2^5
    164165              To:   Finite Field in b of size 2^10
    165166              Defn: a |--> b^8 + b^6 + b^2,
    166              Ring morphism:
    167               From: Finite Field        in a of size 2^5
    168               To:   Finite Field        in b of size 2^10
    169               Defn: a |--> b^9 + b^7 + b^6 + b^5 + b^4]
     167            Ring morphism:
     168              From: Finite Field in a of size 2^5
     169              To:   Finite Field in b of size 2^10
     170              Defn: a |--> b^9 + b^7 + b^6 + b^5 + b^4
     171            ]
    170172        """
    171173        return self.list()[n]
    172174   
  • sage/sets/set.py

    diff -r 808aa5d3d7aa -r 799910270fc3 sage/sets/set.py
    a b class Set_object(Set_generic): 
    449449            25
    450450        """
    451451        try:
    452             if not self.__object.is_finite():
     452            if self.is_finite():
    453453                return sage.rings.infinity.infinity
    454454        except AttributeError:
    455455            pass
    class Set_object(Set_generic): 
    467467            True
    468468            sage: Set(Integers(2^1000000)).is_finite()
    469469            True
     470            sage: Set([1,'a',ZZ]).is_finite()
     471            True
    470472        """
    471         return self.__object.is_finite()
     473        if isinstance(self.__object, (set, frozenset, tuple, list)):
     474            return True
     475        else:
     476            return self.__object.is_finite()
    472477
    473478    def object(self):
    474479        """
  • sage/structure/parent.pyx

    diff -r 808aa5d3d7aa -r 799910270fc3 sage/structure/parent.pyx
    a b cdef class Parent(category_object.Catego 
    385385            sage: len(MatrixSpace(GF(2), 3, 3))
    386386            512
    387387        """
    388         cdef Py_ssize_t total = 0
    389         if self.is_finite():
    390             for x in self:
    391                 total += 1
    392             return total
    393         else:
    394             raise ValueError, "%s has infinite cardinality" % self
     388        return len(self.list())
    395389
    396390    def __getitem__(self, n):
    397391        """