def frac_in(f, t, **kwargs):
 cancel = kwargs.pop('cancel', False)
 if (type(f) is tuple):
  (fa, fd) = f
  f = (fa.as_expr() / fd.as_expr())
 (fa, fd) = f.as_expr().as_numer_denom()
 (fa, fd) = (fa.as_poly(t, **kwargs), fd.as_poly(t, **kwargs))
 if cancel:
  (fa, fd) = fa.cancel(fd, include=True)
 if ((fa is None) or (fd is None)):
  raise ValueError(('Could not turn %s into a fraction in %s.' % (f, t)))
 return (fa, fd)

def frac_in ( f , t , ** kwargs ) : cancel = kwargs . pop ( 'cancel' , False ) if ( type ( f ) is tuple ) : ( fa , fd ) = f f = ( fa . as_expr ( ) / fd . as_expr ( ) ) ( fa , fd ) = f . as_expr ( ) . as_numer_denom ( ) ( fa , fd ) = ( fa . as_poly ( t , ** kwargs ) , fd . as_poly ( t , ** kwargs ) ) if cancel : ( fa , fd ) = fa . cancel ( fd , include = True ) if ( ( fa is None ) or ( fd is None ) ) : raise ValueError ( ( 'Could not turn %s into a fraction in %s.' % ( f , t ) ) ) return ( fa , fd )
returns the tuple .