def is_dyad(frac):
 if (isinstance(frac, numbers.Integral) and (frac >= 0)):
  return True
 elif (isinstance(frac, Fraction) and (frac >= 0) and is_power2(frac.denominator)):
  return True
 else:
  return False

def is_dyad ( frac ) : if ( isinstance ( frac , numbers . Integral ) and ( frac >= 0 ) ) : return True elif ( isinstance ( frac , Fraction ) and ( frac >= 0 ) and is_power2 ( frac . denominator ) ) : return True else : return False
test if frac is a nonnegative dyadic fraction or integer .