Le samedi 30 avril 2011 à 13:36 -0400, Haz a écrit : > So a few things to respond to... > > > Tom: > >Can you describe what went wrong with these branches? In particular, > >why can the following naive strategy not work: > > > >1. Make the new system at least as good as the old one. That is > >whenever I can write foo.is_bar I can write ask(foo, Q.bar) and I > will > >get at least as good an answer. In particular Symbol('x', > >positive=True) should register automatically in the global > assumptions > >that x > 0 (if I understand correctly how the new system works...). > >2. Replace all queries foo.is_bar by ask(foo, Q.bar). > >3. Remove all implementations of the is_bar properties. > >4. Remove all remaining remnants of the old system. > > > This is what was largely tried with a branch last summer: > - https://github.com/haz/sympy/tree/disconnect-assumptions-2 > > > There was push-back from the community since removing the > Symbol('x', positive=True) syntax was largely frowned upon.
As I recall, the problems were that it was slow and broke a lot of things. Symbol(x, positive=True) is easy to hack back in. > > Vinzent: > >I think the only problem could be that ask() is much slower for > >trivial queries, needs to be verified. This should be not too hard to > >fix though. > > > I don't think this is the case. Trivial queries (those that already > have obvious implications) are compiled into quick reference > dictionaries. In particular: > - https://github.com/sympy/sympy/blob/master/sympy/assumptions/ask.py#L114 > I think that the problem is with non-trivial queries, for which that code does nothing. > > In the end, everything in the new assumption system is done with a > particular assumption context -- design decisions must be made on > which context is used in the ambiguous cases. There is also an issue > (feature request) that makes things more natural that will be worked > on after the assumptions shift has taken place -- things like the > following would be possible: > > > with <some assumptions on variables>: > <do stuff> > > > This gives the assumptions an explicit local scope. The branch from > last summer was mostly filled with fixing test cases so they used the > new assumption system (with the global assumptions), and then cleaned > up after themselves. > > > It should also be emphasized that it isn't just a simple notion of > cleaning up assumptions after yourself -- the cache interacts in quite > an intertwined way. Under the right assumptions, expressions will be > simplified, and variables will be assigned certain values. If that's > stored in the cache, changing any related assumption will invalidate > the result. For this reason, I had to manually clear the cache on a > regular basis. I think that the cache is only really needed for > lengthy solve algorithms (so you don't recompute an expression over > and over), in which case we can probably wipe it after any sympy > command is invoked (i.e., only use the cache while sympy is computing > things, and then flush it just before returning the result). However, > the branches from last summer never made it this far. > The cache is the source of a lot of problems. We should try to use it as little as possible, even if it's not really possible to remove it at this time. > > I think a few things are generally universally accepted (correct me > if I'm wrong though): > 1. sympy/core/assumptions.py should be removed, and everything patched > up to use sympy/assumptions/* > 2. sympy/core/logic.py should be removed and replaced with > sympy/logic/* > 3. Assumptions should probably have the right references to be > properly deleted from a context when their symbol is deleted -- this > goes for any AssumptionContext (not just the global one) > I'm not sure about 1: sympy/core/assumptions.py and sympy/assumptions/* should be merged, but I don't know how exactly the merge should happen. > > Ronan: Can you elaborate on this? (my memory is failing me at the > moment) > > * Remove the cumbersome and confusing Assume() syntax The idea is to write '~Q.real(x)' instead of 'Assume(x, Q.real, False)'. It's shorter, easier to understand and doesn't suggest wrongly that creating the object does anything beyond that. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.