On Nov 25, 2007 6:33 PM, David Roe <[EMAIL PROTECTED]> wrote: > Addition not commuting there bothers me. I can see why it's happening: a > SymPy object doesn't call into the coercion system. One possible solution > is to have coercion map sage objects into sympy, so both s+o and o+s (in > line 134 and 135 of test_sympy.py) would be SymPy objects. Is SymPy and the > SymbolicRing canonically isomorphic? Can every SymbolicRing element be cast > into SymPy?
I don't think so, since probably sage/maxima have special functions sympy doesn't. And even if it could be, the functions provided by SymPy are different than the ones provided by SymbolicRing. If sympy('x') + x and x + sympy('x') are totally different in Sage I will be unhappy about that. Either the result has to always be in SymPy or always in Sage or we have to get an error and request that the user explicitly do a coercion. We have to decide on a canonical map in exactly one direction, and I prefer SymPy ---> SymbolicRing, just because SymbolicRing is more native in Sage, and probably could be improved so it would support any SymPy expression (yes -- I know this isn't true now, unfortunately). Now that I read through #1189 patch, I'm uncomfortable with return _verify_canonical_coercion_c(x,y) The function _verify_canonical_coercion_c is supposed to be like assert(parent(x) is parent(y)) it's *never* supposed to be called when the parents are different -- if it is, that means there is a bug. However, you're using it to test whether the parents are different, and if so do some other behavior (i.e., eventually raise a TypeError). So that makes me nervous. It would be better to just directly do a call to the have_same_parent function, like in the implementation of _verify_canonical_coercion_c in coerce.pxi. In summary, the way the code is written now will work fine now, but seems a little abusive. --~--~---------~--~----~------------~-------~--~----~ 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/ -~----------~----~----~----~------~----~------~--~---