Given the comments of both of you I propose the following addition
(isolated to the rules module in order not to cause too much arguing):

- adding a gather_rules function that traverses the tree and checks
for any rules registered with the objects. For instance
my_very_special_matrix object will have the following property

my_very_special_matrix.rules_register = {'simplify':
[the_rule_square_is_identity,]}

and trace will have

Trace.rules_register = {'canonicalize': [trace_unpack_scalar, ]}

This will be slow, but it will permit great freedom. We can optimize it later.

It will also work with the ugly idea that I had about calling all the
constructors.

ClassUnsupportedByRules.rule_register = {'canonicalize':
[call_the_constructor, ]}

On 2 November 2012 16:42, Stefan Krastanov <[email protected]> wrote:
>> How do you get Matrix => scalar?
> very_special_matrix**2 is equal to scalar*Identity. The scalar is
> (should be) factored out of the Trace.
>
>>> points to consider:
>>>
>>> 1. I want to use only the following custom rule:
>>> very_special_matrix_a**2 -> scalar*Identity
>
>
>
>
>> Why is Trace not auto evaluated?  I suppose you're creating it via
>> Basic__new__ rather than the Trace constructor? This is getting to the
>> issue that Ronan foresaw in the original pull request. Basic.__new__
>> seemed ok to me, but only to create the original object. Using it to
>> create new objects instead of their constructors is a bad idea.
>
> The way that trace works is not based on canonicalization in the
> constructor (or at least when it is fixed it wont be) hence my
> disagreement with your comment and Ronan.

-- 
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.

Reply via email to