Hi Fabian! On Sat, Feb 21, 2009 at 2:50 AM, Fabian Seoane <[email protected]> wrote: > Hi all. As part of my work in the assumptions branch[1], I'm faced to the > problem of finding a new syntax for the expr.is_* property. > > It seems that last time we talked about it, we used the following syntax for > querying an element (although we did not discuss it) > > IsPositive(x) > IsElement(x) > etc. > > This is ok, but I find it cumbersome to have so many methods (at least one > for each assumption we support). Alternatively, my implementation > proposes another solution based on the query method. You can see it's > implementation here [2]. Examples would look like: > > query(x, 'positive') > query(x, 'real') > > It works the following way: > Each query key ('positive', 'real') defines a QueryHandler that is > responsible for handling the resolution of the current query. Then > query_dict maps each assumption > to it's handler. Of course we could define shortcuts: > > def IsPositive(x): > return query(x, 'positive') > > The nice thing here is extensibility: If any third-party module would like > to add new query keys (query(x, 'my_key')), just append the appropriate > handler to query_dict (all this is better understood looking at [2]). > > Of course, Is* syntax can also be made extensible by subclassing, so it all > comes at the end to a matter of consistency. > > Any comments? Which syntax do you prefer ?
Thanks for working on it. I think your approach is fine. We can always define such methods, or properties if needed (like is_positive). Important is, that the assumptions will be detached from the expression, because then we can merge the cython core in. 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 -~----------~----~----~----~------~----~------~--~---
