Ticket #5777: trac_5777-11-hash_doctests.patch

File trac_5777-11-hash_doctests.patch, 1.5 KB (added by burcin, 11 years ago)

add doctests for exceptions raised during hashing

  • sage/symbolic/expression.pyx

    # HG changeset patch
    # User Burcin Erocal <burcin@erocal.org>
    # Date 1241564686 -7200
    # Node ID ee6415a94611aacf0c97a4e38df4ea327691366a
    # Parent  81142fc2ecb735799952395b1f239dca3cad8517
    Add doctests to symbolics for matrix vector multiplication and handling exceptions during hashing.
    
    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    7979    a^2 + 2*a*b + 2*a*c + b^2 + 2*b*c + c^2 + (2*u + 2*v)*a + (2*u + 2*v)*b + (2*u + 2*v)*c + u^2 + 2*u*v + v^2
    8080
    8181TESTS:
    82     Test jacobian on pynac expressions. #5546 ::
     82
     83Test jacobian on pynac expressions. #5546 ::
     84
    8385    sage: var('x,y', ns=1)
    8486    (x, y)
    8587    sage: f = x + y
    8688    sage: jacobian(f, [x,y])
    8789    [1 1]
    88    
     90
     91
     92Test if matrices work #5546 ::
     93
     94    sage: var('x,y,z', ns=1)
     95    (x, y, z)
     96    sage: M = matrix(2,2,[x,y,z,x])
     97    sage: v = vector([x,y])
     98    sage: M * v
     99    (x^2 + y^2, x*y + x*z)
     100    sage: v*M
     101    (x^2 + y*z, 2*x*y)
     102
    89103"""
    90104
    91105include "../ext/interrupt.pxi"
     
    605619            sage: d = {x+y: 5}
    606620            sage: d
    607621            {x + y: 5}
     622
     623        TESTS:
     624
     625        Test if exceptions during hashing are handled properly::
     626
     627            sage: t = S(matrix(2,2,range(4)))
     628            sage: hash(t)
     629            Traceback (most recent call last):
     630            ...
     631            TypeError: mutable matrices are unhashable
    608632        """
    609633        return self._gobj.gethash()
    610634