class_docstr: Context for multiprecision arithmetic with a global precision.
class_docstr_tok: ["Context","for","multiprecision","arithmetic","with","a","global","precision","."]
code: def hypsum(
      ctx, p, q, flags, coeffs, z, accurate_small=True, **kwargs
  ):
      if hasattr(z, "_mpf_"):
          key = p, q, flags, "R"
          v = z._mpf_
      elif hasattr(z, "_mpc_"):
          key = p, q, flags, "C"
          v = z._mpc_
      if key not in ctx.hyp_summators:
          ctx.hyp_summators[key] = libmp.make_hyp_summator(key)[1]
      summator = ctx.hyp_summators[key]
      prec = ctx.prec
      maxprec = kwargs.get("maxprec", ctx._default_hyper_maxprec(prec))
      extraprec = 50
      epsshift = 25
      # Jumps in magnitude occur when parameters are close to negative
      # integers. We must ensure that these terms are included in
      # the sum and added accurately
      magnitude_check = {}
      max_total_jump = 0
      for i, c in enumerate(coeffs):
          if flags[i] == "Z":
              if i >= p and c <= 0:
                  ok = False
                  for ii, cc in enumerate(coeffs[:p]):
                      # Note: c <= cc or c < cc, depending on convention
                      if flags[ii] == "Z" and cc <= 0 and c <= cc:
                          ok = True
                  if not ok:
                      raise ZeroDivisionError(
                          "pole in hypergeometric series"
                      )
              continue
          n, d = ctx.nint_distance(c)
          n = -int(n)
          d = -d
          if i >= p and n >= 0 and d > 4:
              if n in magnitude_check:
                  magnitude_check[n] += d
              else:
                  magnitude_check[n] = d
              extraprec = max(extraprec, d - prec + 60)
          max_total_jump += abs(d)
      while 1:
          if extraprec > maxprec:
              raise ValueError(
                  ctx._hypsum_msg % (prec, prec + extraprec)
              )
          wp = prec + extraprec
          if magnitude_check:
              mag_dict = dict((n, None) for n in magnitude_check)
          else:
              mag_dict = {}
          zv, have_complex, magnitude = summator(
              coeffs, v, prec, wp, epsshift, mag_dict, **kwargs
          )
          cancel = -magnitude
          jumps_resolved = True
          if extraprec < max_total_jump:
              for n in mag_dict.values():
                  if (n is None) or (n < prec):
                      jumps_resolved = False
                      break
          accurate = cancel < extraprec - 25 - 5 or not accurate_small
          if jumps_resolved:
              if accurate:
                  break
              # zero?
              zeroprec = kwargs.get("zeroprec")
              if zeroprec is not None:
                  if cancel > zeroprec:
                      if have_complex:
                          return ctx.mpc(0)
                      else:
                          return ctx.zero
  
          # Some near-singularities were not included, so increase
          # precision and repeat until they are
          extraprec *= 2
          # Possible workaround for bad roundoff in fixed-point arithmetic
          epsshift += 5
          extraprec += 5
  
      if type(zv) is tuple:
          if have_complex:
              return ctx.make_mpc(zv)
          else:
              return ctx.make_mpf(zv)
      else:
          return zv
  
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 34 for calling the MPContext obj's underlying member method code with example usage: obj.hypsum(ctx, p, q, flags, coeffs, z, accurate_small) and returns: zv, ctx, ctx, ctx, ctx