Hi, On Wed, May 13, 2009 at 08:42:27AM +0300, Priit Laes wrote: > > Hey! > > Could someone elaborate why following examples return true: > > Rational(1).is_fraction() == True > (x**2).is_fraction() == True > > > It doesn't just seem logical to me as fractions come usually in form of > x/a (a != 1) or 0.75. >
this function should read is_rational_function, e.g.: In [1]: (x/y).is_fraction(x, y) Out[1]: True In [2]: (x/sin(y)).is_fraction(x, y) Out[2]: False In [3]: (x/sin(y)).is_fraction(x) Out[3]: True In [4]: (x/sin(y)).is_fraction() Out[4]: False It tests if numerator and denominator are polynomials in the given symbols (Basic.atoms(Symbol) is used when no symbols were passed to this function). btw1. You can use Basic.is_fraction?? in IPython to see non-existent docstring and source code fast, to answer such questions your self :) btw2. It would be good to write a docstring for this function to avoid confusion in future. This function can be also renamed or removed, as it's not much useful anyway. -- Mateusz
signature.asc
Description: This is a digitally signed message part