def dyad_completion(w):
 w = tuple((Fraction(v) for v in w))
 d = max((v.denominator for v in w))
 p = next_pow2(d)
 if (p == d):
  return w
 else:
  return (tuple((Fraction((v * d), p) for v in w)) + (Fraction((p - d), p),))

def dyad_completion ( w ) : w = tuple ( ( Fraction ( v ) for v in w ) ) d = max ( ( v . denominator for v in w ) ) p = next_pow2 ( d ) if ( p == d ) : return w else : return ( tuple ( ( Fraction ( ( v * d ) , p ) for v in w ) ) + ( Fraction ( ( p - d ) , p ) , ) )
return the dyadic completion of w .