コード例 #1
0
 def _convert_tol(self, tol):
     if isinstance(tol, int_types):
         return from_int(tol)
     if isinstance(tol, float):
         return from_float(tol)
     if hasattr(tol, '_mpf_'):
         return tol._mpf_
     prec, rounding = self._prec_rounding
     if isinstance(tol, str):
         return from_str(tol, prec, rounding)
     raise ValueError(f'expected a real number, got {tol}')
コード例 #2
0
 def _convert_tol(ctx, tol):
     if isinstance(tol, int_types):
         return from_int(tol)
     if isinstance(tol, float):
         return from_float(tol)
     if hasattr(tol, "_mpf_"):
         return tol._mpf_
     prec, rounding = ctx._prec_rounding
     if isinstance(tol, basestring):
         return from_str(tol, prec, rounding)
     raise ValueError("expected a real number, got %s" % tol)
コード例 #3
0
ファイル: mpelements.py プロジェクト: asmeurer/sympy
 def _convert_tol(ctx, tol):
     if isinstance(tol, int_types):
         return from_int(tol)
     if isinstance(tol, float):
         return from_float(tol)
     if hasattr(tol, "_mpf_"):
         return tol._mpf_
     prec, rounding = ctx._prec_rounding
     if isinstance(tol, string_types):
         return from_str(tol, prec, rounding)
     raise ValueError("expected a real number, got %s" % tol)