And of course, after I type that, I check, and I see that that exact
thing is already implemented. So it should be using that.

Aaron Meurer

On Fri, Jul 18, 2014 at 10:56 PM, Aaron Meurer <asmeu...@gmail.com> wrote:
> Yes, it should do it. It was just an oversight I'm sure. Maybe Symbol
> should have an as_dummy method for such situations that produces a
> Dummy variable with the same assumptions.
>
> Aaron Meurer
>
> On Fri, Jul 18, 2014 at 8:54 PM, Keaton Burns <keaton.bu...@gmail.com> wrote:
>> Thanks, that's working great.  Is there a reason not to just pass the
>> commutative assumptions to the dummy variables, with "d =
>> Dummy(commutative=expr.is_commutative)"?  This seems to work for my cases.
>>
>> On Friday, July 18, 2014 9:18:46 PM UTC-4, Aaron Meurer wrote:
>>>
>>> It looks like it's because when simultaneous=True (the default), it
>>> uses Dummy symbols, which do not keep the assumptions of the symbols
>>> they replace. If you set simultaneous=False, it works correctly.
>>>
>>> Aaron Meurer
>>>
>>> On Fri, Jul 18, 2014 at 1:52 PM, Keaton Burns <keaton...@gmail.com> wrote:
>>> > Hello,
>>> >
>>> > I'm using the "replace" method to substitute a function symbol with a
>>> > python
>>> > lambda function, but this process is failing to respect
>>> > non-commutativity.
>>> > This can be seen with a simple example:
>>> >
>>> >>>> import sympy as sy
>>> >>>>
>>> >>>> x, y = sy.symbols('x, y', commutative=False)
>>> >>>> f = sy.Function('f')
>>> >>>> expression = x * f(y)
>>> >>>>
>>> >>>> # Replace f with trivial lambda function, expect x*y
>>> >>>> expression.replace(f, lambda x: x)
>>> > y*x
>>> >
>>> > Using "subs" seems to respect non-commutativity just fine, but I don't
>>> > know
>>> > the exact patterns that I'll need to be replacing (i.e. I want to apply
>>> > the
>>> > lambda to whatever arguments f happens to have).
>>> >
>>> > If there isn't a quick fix for replace, is there another way to achieve
>>> > this
>>> > sort of function substitution?
>>> >
>>> > Thanks,
>>> > Keaton
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "sympy" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to sympy+un...@googlegroups.com.
>>> > To post to this group, send email to sy...@googlegroups.com.
>>> > Visit this group at http://groups.google.com/group/sympy.
>>> > To view this discussion on the web visit
>>> >
>>> > https://groups.google.com/d/msgid/sympy/fad5c2d6-7749-4bd4-9fcf-5ba2c813eb0a%40googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sympy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sympy@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/44b62f4b-149d-4ea3-913c-2f36d855fe87%40googlegroups.com.
>>
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6K9iTF0np3LdoMVajpy55py8NbM8FMzkbBDDSAF0y5nkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to