Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Add tests for _add_long and _mul_long
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Sep 8, 2016
1 parent fec4abe commit 25c9d7d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/sage/structure/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,20 @@ cdef class Element(SageObject):
cdef _add_long(self, long n):
"""
Generic path for adding a C long, assumed to commute.
EXAMPLES::
sage: cython( # long time
....: '''
....: from sage.structure.element cimport Element
....: cdef class MyElement(Element):
....: cdef _add_long(self, long n):
....: return n
....: ''')
sage: e = MyElement(Parent()) # long time
sage: i = int(42)
sage: i + e, e + i # long time
(42, 42)
"""
return coercion_model.bin_op(self, n, add)

Expand Down Expand Up @@ -1517,6 +1531,20 @@ cdef class Element(SageObject):
cdef _mul_long(self, long n):
"""
Generic path for multiplying by a C long, assumed to commute.
EXAMPLES::
sage: cython( # long time
....: '''
....: from sage.structure.element cimport Element
....: cdef class MyElement(Element):
....: cdef _mul_long(self, long n):
....: return n
....: ''')
sage: e = MyElement(Parent()) # long time
sage: i = int(42)
sage: i * e, e * i # long time
(42, 42)
"""
return coercion_model.bin_op(self, n, mul)

Expand Down

0 comments on commit 25c9d7d

Please sign in to comment.