parameters: (a, denom)
return_statement: return tuple(Fraction(v, denom) for v in b)
docstring: Approximate ``a/sum(a)`` with tuple of fractions with denominator *exactly* ``denom``.
  
      >>> a = [.123, .345, .532]
      >>> make_frac(a,10)
      (Fraction(1, 10), Fraction(2, 5), Fraction(1, 2))
      >>> make_frac(a,100)
      (Fraction(3, 25), Fraction(7, 20), Fraction(53, 100))
      >>> make_frac(a,1000)
      (Fraction(123, 1000), Fraction(69, 200), Fraction(133, 250))
docstring_summary: Approximate ``a/sum(a)`` with tuple of fractions with denominator *exactly* ``denom``.
docstring_tokens: Approximate a / sum ( a ) with tuple of fractions with denominator * exactly * denom .
function: def make_frac(a, denom):
      """ Approximate ``a/sum(a)`` with tuple of fractions with denominator *exactly* ``denom``.
  
      >>> a = [.123, .345, .532]
      >>> make_frac(a,10)
      (Fraction(1, 10), Fraction(2, 5), Fraction(1, 2))
      >>> make_frac(a,100)
      (Fraction(3, 25), Fraction(7, 20), Fraction(53, 100))
      >>> make_frac(a,1000)
      (Fraction(123, 1000), Fraction(69, 200), Fraction(133, 250))
      """
  
      a = np.array(a, dtype=float)/sum(a)
      b = [float(v*denom) for v in a]
      b = np.array(b, dtype=int)
      err = b/float(denom) - a
  
      inds = np.argsort(err)[:(denom - sum(b))]
      b[inds] += 1
  
      denom = np.int32(denom)
      b = b.tolist()
  
      return tuple(Fraction(v, denom) for v in b)
function_tokens: def make_frac ( a , denom ) : a = np . array ( a , dtype = float ) / sum ( a ) b = [ float ( v * denom ) for v in a ] b = np . array ( b , dtype = int ) err = b / float ( denom ) - a inds = np . argsort ( err ) [ : ( denom - sum ( b ) ) ] b [ inds ] += 1 denom = np . int32 ( denom ) b = b . tolist ( ) return tuple ( Fraction ( v , denom ) for v in b )