> yes, that's one of the main reasons behind writing the module!.

Great!

> I'll show by example how to create a new query without touching any file
> in sympy's codebase :
>
> In [1]: from sympy.query import QueryHandler, handlers_dict
>
> In [2]: class AssociativeQueryHandler(QueryHandler):
>    ...:     def Symbol(self):
>    ...:         return True # we know Symbols are associative
>    ...:     def Number(self):
>    ...:         return True
>    ...:
>
> In [3]: handlers_dict.update({'associative': AssociativeQueryHandler}) #
> we tell the assumptions system that the associative query will be
> handled by our class
>
> In [4]: query(x, associative=True) # voilá !
> Out[4]: True
>
> In [5]: query(3, associative=True)
> Out[5]: True
>
> As you see, you can add/remove query handlers at runtime without much
> trouble.

Wow, this is absolutely fantastic.  One question though.  Let's say
two different packages define some new Sympy objects and some queries
along with them.  And let's say that merely importing those packages
causes them to register their queries under the same key.

Making it more concrete, if package foo and bar both call:

handlers_dict.update({'associative': FooAssociativeQueryHandler})
handlers_dict.update({'associative': BarAssociativeQueryHandler})

What will happen?  If I am reading your code correctly, the last one
wins.  If I need to use package foo and package bar (written by
different folks possibly) in my own code, I can't.

Am I understanding this correctly?  If so, I would consider this a bug.

This usage case could be very common as we make it easier for others
to create sympy types with assumptions.

Overall though, I think this will be a huge improvement over the
current assumption system.  Great job!

Cheers,

Brian

> PS: this whole structure is similar to the one you described in (3) in
> the thread "expansion refactoring"

Yes, very much so!

>>
>> Cheers,
>>
>> Brian
>>
>>
>>
>> On Wed, Jun 10, 2009 at 8:20 AM, Fabian Pedregosa<fab...@fseoane.net> wrote:
>>> The following are a series of patches that implement the new assumption 
>>> system, which
>>> consists of:
>>>
>>>   - preparatory stuff (patches 1-5)
>>>   - a logic module (much cleaner than the old one)
>>>   - new style-assumptions (very simple objects)
>>>   - query module, which substitutes the .is_* syntax
>>>
>>> I tried hard to separate these 3 functionalities as much as possible.
>>>
>>> This is more an initial implementation from whom we can star to work rather 
>>> than a
>>> finished product, so in case you have any objections, we can start 
>>> discussing.
>>>
>>> Thanks for the review,
>>>
>>> - Fabian
>>>
>>> pd: patch 3 was already approved, just that i did not push it in.
>>>
>>>
>>
>> >
>>
>
>
> --
> http://fseoane.net/blog/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to