On Sep 12, 2007, at 7:17 PM, Ondrej Certik wrote: >> sage: sin.is_zero() >> False > > What should this particular line do? I don't understand the doctest > for is_zero either: > > " > Return True if self equals self.parent()(0). The default > implementation is to fall back to 'not self.__nonzero__'. > "
Would it be better to say "Return True if self is the zero element in its parent." Here 'sin' is not the zero expression, so we return False. However, sage: (sin - sin).is_zero() # this is equal to the zero expression True (Of course, depending on the limitations of the underlying symbolic engine, it may give false negatives.) > I understand this though: > > sage: sin(0).is_zero() > True > sage: sin(1).is_zero() > False > > >> I don't see the latter ever getting used, or even being exposed. It >> seems as unnatural as >> >> sage: import types >> sage: types.IntType(4) # instead of using int(4) > > Well, I can see a difference: > > sage: type(sin) > <class 'sage.calculus.calculus.Function_sin'> > sage: type(4) > <type 'sage.rings.integer.Integer'> >>>> type(4) > <type 'int'> > > so basically the "type" says what is the class of that instance. So 4 > is an instance of int or Integer in SAGE and thus should be > instantiated using int(4), or just using a syntactic sugar: 4. On the > other hand sin is an instance of Function_sin, but it shouldn't be > instantiated by Function_sin(). It seems to me like some kind of > magic, that I type "sin" and some instance of a class that I am not > supposed to import is returned. Note that we do the same in sympy > currently. I think of it as pre-populating the namespace with common and useful classes, functions, and objects, among them is a well named instance of Function_sin. Whether or not that is magical is a matter of opinion, but I think it obeys the principle of least surprise for the end user. > Nevertheless, it's not a big deal anyway. I just wanted to know your > opinions about this. Thanks a lot for all the ideas you wrote. > > Ondrej Thank you for posting your questions here, I think it's generated a good discussion. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---