Related to this, how have people done unit testing of sympy related code? If for example, we expect a calculation to result in, 8.0*J*S*(1-cos(q)),
and it instead results in: 7.999999*J*S*(1-cos(q)) then unit tests will fail. I assume that cmp is comparing hashes and as the floating point numbers are different, the hashes must be different. Is there something close to the AssertAlmostEqual in unitTest. My current solution is to punt and just insert values for the symbols and test numerically, but it would be nicer to test symbolically.... Cheers, William On Sat, Jul 18, 2009 at 5:35 PM, Ondrej Certik <[email protected]> wrote: > > On Sat, Jul 18, 2009 at 3:31 PM, Vinzent > Steinberg<[email protected]> wrote: > > > > On Jul 8, 10:38 pm, Fredrik Johansson <[email protected]> > > wrote: > >> On Wed, Jul 8, 2009 at 10:07 PM, Ondrej Certik<[email protected]> wrote: > >> > so I am confused about those digits at the end. But apparently they > >> > can't be trusted. > >> > >> This is arguably not a bug. It's hard to determine whether a given > >> decimal expansion that goes "999..." or "000..." should be rounded up > >> or down. The only way to do it is to continue calculating until a > >> digit other than 9 or 0 appears, and in general it's impossible to > >> tell whether trying will get you stuck in an infinite loop. > >> > >> You could write function (or add an evalf option) that tries to find n > >> digits, and make it look for trailing 9's or 0's, but you'd have to > >> implement some stopping criterion. > > > > I think we should just add an option that specifies the maximal number > > of trailing 9's or 0's to look for, and set a reasonable default for > > it. > > I think there is no reasonable default, as this example shows. I would > just leave it as is, I didn't realize there is no easy fix. > > Ondrej > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
