class_docstr: Context for multiprecision arithmetic with a global precision.
class_docstr_tok: ["Context","for","multiprecision","arithmetic","with","a","global","precision","."]
docstr: Given Python integers `(p, q)`, returns a lazy ``mpf`` representing
  the fraction `p/q`. The value is updated with the precision.
  
      >>> from mpmath import *
      >>> mp.dps = 15
      >>> a = fraction(1,100)
      >>> b = mpf(1)/100
      >>> print(a); print(b)
      0.01
      0.01
      >>> mp.dps = 30
      >>> print(a); print(b)      # a will be accurate
      0.01
      0.0100000000000000002081668171172
      >>> mp.dps = 15
docstr_tok: ["Given","Python","integers","`","(","p",",","q",")","`",",","returns","a","lazy","``","mpf","``","representing","the","fraction","`","p\/q","`",".","The","value","is","updated","with","the","precision",".",">",">",">","from","mpmath","import","*",">",">",">","mp.dps","=","15",">",">",">","a","=","fraction","(","1,100",")",">",">",">","b","=","mpf","(","1",")","\/100",">",">",">","print","(","a",")",";","print","(","b",")","0.01","0.01",">",">",">","mp.dps","=","30",">",">",">","print","(","a",")",";","print","(","b",")","#","a","will","be","accurate","0.01","0.0100000000000000002081668171172",">",">",">","mp.dps","=","15"]
code: def fraction(ctx, p, q):
      """
      Given Python integers `(p, q)`, returns a lazy ``mpf`` representing
      the fraction `p/q`. The value is updated with the precision.
  
          >>> from mpmath import *
          >>> mp.dps = 15
          >>> a = fraction(1,100)
          >>> b = mpf(1)/100
          >>> print(a); print(b)
          0.01
          0.01
          >>> mp.dps = 30
          >>> print(a); print(b)      # a will be accurate
          0.01
          0.0100000000000000002081668171172
          >>> mp.dps = 15
      """
      return ctx.constant(
          lambda prec, rnd: from_rational(p, q, prec, rnd),
          "%s/%s" % (p, q),
      )
  
imports: import functools
  import re
  from .ctx_base import StandardBaseContext
  from .libmp.backend import basestring, BACKEND
  from .None import libmp
  from .libmp import MPZ, MPZ_ZERO, MPZ_ONE, int_types, repr_dps, round_floor, round_ceiling, dps_to_prec, round_nearest, prec_to_dps, ComplexResult, to_pickable, from_pickable, normalize, from_int, from_float, from_str, to_int, to_float, to_str, from_rational, from_man_exp, fone, fzero, finf, fninf, fnan, mpf_abs, mpf_pos, mpf_neg, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_rdiv_int, mpf_pow_int, mpf_mod, mpf_eq, mpf_cmp, mpf_lt, mpf_gt, mpf_le, mpf_ge, mpf_hash, mpf_rand, mpf_sum, bitcount, to_fixed, mpc_to_str, mpc_to_complex, mpc_hash, mpc_pos, mpc_is_nonzero, mpc_neg, mpc_conjugate, mpc_abs, mpc_add, mpc_add_mpf, mpc_sub, mpc_sub_mpf, mpc_mul, mpc_mul_mpf, mpc_mul_int, mpc_div, mpc_div_mpf, mpc_pow, mpc_pow_mpf, mpc_pow_int, mpc_mpf_div, mpf_pow, mpf_pi, mpf_degree, mpf_e, mpf_phi, mpf_ln2, mpf_ln10, mpf_euler, mpf_catalan, mpf_apery, mpf_khinchin, mpf_glaisher, mpf_twinprime, mpf_mertens, int_types
  from .None import function_docs
  from .None import rational
  from .ctx_mp_python import _mpf, _mpc, mpnumeric
label_desc: Use image node_id 45 for calling the MPContext obj's underlying member method code with example usage: obj.fraction(ctx, p, q) and returns: ctx