Ticket #13215: trac_13641_short_repr_morphism.patch

File trac_13641_short_repr_morphism.patch, 1.2 KB (added by caruso, 9 years ago)
  • sage/categories/morphism.pyx

    # HG changeset patch
    # User Xavier Caruso <xavier.caruso@normalesup.org>
    # Date 1350908367 -7200
    # Node ID 20d203e49091630a94546573b3a12b5f5390c1b4
    # Parent  dc82ebdd68ec2977b5b66363ab2e36a8a315c61c
    imported patch short_repr_morphisms.patch
    
    diff --git a/sage/categories/morphism.pyx b/sage/categories/morphism.pyx
    a b  
    6060            s += "\n  Defn: %s"%('\n        '.join(self._repr_defn().split('\n')))
    6161        return s
    6262
     63    def _short_repr(self):
     64        """
     65        Return a short string representation of this morphism.
     66        EXAMPLES:
     67
     68            sage: R.<t> = ZZ[]
     69            sage: f = R.hom([t+1])
     70            sage: f
     71            Ring endomorphism of Univariate Polynomial Ring in t over Integer Ring
     72              Defn: t |--> t + 1
     73            sage: f._short_repr()
     74            't |--> t + 1'
     75
     76        AUTHOR:
     77
     78        - Xavier Caruso (2012-06-29)
     79        """
     80        d = self._repr_defn()
     81        if d == "":
     82            return self._repr_()
     83        else:
     84            return ", ".join(d.split("\n"))
     85
    6386    def category(self):
    6487        return self.parent().category() # Shouln't it be Category of elements of ...?
    6588