Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build/pkgs/mpmath/spkg-check.in #36447

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/pkgs/mpmath/dependencies_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
----------
All lines of this file are ignored except the first.
1 change: 1 addition & 0 deletions build/pkgs/mpmath/spkg-check.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
11 changes: 11 additions & 0 deletions src/sage/libs/mpmath/ext_main.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ context class, and related utilities.
# http://www.gnu.org/licenses/
#*****************************************************************************

import numbers

from cpython.long cimport *
from cpython.float cimport *
from cpython.complex cimport *
Expand Down Expand Up @@ -161,6 +163,11 @@ cdef int MPF_set_any(MPF *re, MPF *im, x, MPopts opts, bint str_tuple_ok) except
#MPF_set_tuple(re, libmp.from_rational(p, q, opts.prec,
# rndmode_to_python(opts.rounding)))
return 1
if isinstance(x, numbers.Rational):
p, q = x.numerator, x.denominator
MPF_set_tuple(re, libmp.from_rational(p, q, opts.prec,
rndmode_to_python(opts.rounding)))
return 1
if hasattr(x, '_mpi_'):
a, b = x._mpi_
if a == b:
Expand Down Expand Up @@ -1600,6 +1607,8 @@ cdef class mpnumber:
mpf('3.0')
"""
return binop(OP_DIV, self, other, global_opts)
__div__ = __truediv__
__rdiv__ = __truediv__

def __mod__(self, other):
"""
Expand Down Expand Up @@ -2144,6 +2153,8 @@ cdef class mpf(mpf_base):
"""
return binop(OP_RICHCMP+op, self, other, global_opts)

def __round__(self, *args):
return round(float(self), *args)


cdef class constant(mpf_base):
Expand Down
Loading