"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/ctx_mp_python.py" between
mpmath-0.19.tar.gz and mpmath-1.0.0.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

ctx_mp_python.py  (mpmath-0.19):ctx_mp_python.py  (mpmath-1.0.0)
skipping to change at line 143 skipping to change at line 143
def __repr__(s): def __repr__(s):
if s.context.pretty: if s.context.pretty:
return str(s) return str(s)
return "mpf('%s')" % to_str(s._mpf_, s.context._repr_digits) return "mpf('%s')" % to_str(s._mpf_, s.context._repr_digits)
def __str__(s): return to_str(s._mpf_, s.context._str_digits) def __str__(s): return to_str(s._mpf_, s.context._str_digits)
def __hash__(s): return mpf_hash(s._mpf_) def __hash__(s): return mpf_hash(s._mpf_)
def __int__(s): return int(to_int(s._mpf_)) def __int__(s): return int(to_int(s._mpf_))
def __long__(s): return long(to_int(s._mpf_)) def __long__(s): return long(to_int(s._mpf_))
def __float__(s): return to_float(s._mpf_) def __float__(s): return to_float(s._mpf_, rnd=s.context._prec_rounding[1])
def __complex__(s): return complex(float(s)) def __complex__(s): return complex(float(s))
def __nonzero__(s): return s._mpf_ != fzero def __nonzero__(s): return s._mpf_ != fzero
__bool__ = __nonzero__ __bool__ = __nonzero__
def __abs__(s): def __abs__(s):
cls, new, (prec, rounding) = s._ctxdata cls, new, (prec, rounding) = s._ctxdata
v = new(cls) v = new(cls)
v._mpf_ = mpf_abs(s._mpf_, prec, rounding) v._mpf_ = mpf_abs(s._mpf_, prec, rounding)
return v return v
skipping to change at line 396 skipping to change at line 396
if s.context.pretty: if s.context.pretty:
return str(s) return str(s)
r = repr(s.real)[4:-1] r = repr(s.real)[4:-1]
i = repr(s.imag)[4:-1] i = repr(s.imag)[4:-1]
return "%s(real=%s, imag=%s)" % (type(s).__name__, r, i) return "%s(real=%s, imag=%s)" % (type(s).__name__, r, i)
def __str__(s): def __str__(s):
return "(%s)" % mpc_to_str(s._mpc_, s.context._str_digits) return "(%s)" % mpc_to_str(s._mpc_, s.context._str_digits)
def __complex__(s): def __complex__(s):
return mpc_to_complex(s._mpc_) return mpc_to_complex(s._mpc_, rnd=s.context._prec_rounding[1])
def __pos__(s): def __pos__(s):
cls, new, (prec, rounding) = s._ctxdata cls, new, (prec, rounding) = s._ctxdata
v = new(cls) v = new(cls)
v._mpc_ = mpc_pos(s._mpc_, prec, rounding) v._mpc_ = mpc_pos(s._mpc_, prec, rounding)
return v return v
def __abs__(s): def __abs__(s):
prec, rounding = s.context._prec_rounding prec, rounding = s.context._prec_rounding
v = new(s.context.mpf) v = new(s.context.mpf)
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)