My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 784: .match(g1 * log(gamma) + g2 * gamma + g3) doesn't work
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Dec 2012

Restricted
  • Only users with Commit permission may comment.


Sign in to add a comment
 
Project Member Reported by ondrej.c...@gmail.com, Apr 14, 2008
In [1]: from sympy import *

In [2]: from sympy.abc import mu, gamma, x

In [3]: f = (- gamma * (x-mu)**2 - log(gamma) + log(2*pi)) / 2

In [4]: g1 = Wild('g1', exclude=[gamma])

In [5]: g2 = Wild('g2', exclude=[gamma])

In [6]: g3 = Wild('g3', exclude=[gamma])

In [7]: print f.expand().match(g1 * log(gamma) + g2 * gamma + g3)
None

Apr 27, 2008
Project Member #1 ondrej.c...@gmail.com
(No comment was entered for this change.)
Labels: wrong-result
May 21, 2008
Project Member #2 rwnobrega
(No comment was entered for this change.)
Labels: WrongResult
May 21, 2008
Project Member #3 rwnobrega
(No comment was entered for this change.)
Labels: -wrong-result
Dec 2, 2009
Project Member #4 Ronan.L...@gmail.com
(No comment was entered for this change.)
Labels: Matching
Mar 20, 2012
Project Member #5 asmeurer@gmail.com
(No comment was entered for this change.)
Status: Valid
Sep 12, 2012
Project Member #6 julien.r...@gmail.com
This works if you collect before matching, i.e. f.expand().collect(gamma).match(g1 * log(gamma) + g2 * gamma + g3). I think this behavior is correct.
Sep 13, 2012
Project Member #7 julien.r...@gmail.com
Tests were added for this issue. If you agree, we can close it.
Sep 13, 2012
Project Member #8 asmeurer@gmail.com
I don't know.  Should match try to be smart or just do structural matching?  It's the same problem that's been discussed a dozen times with subs.
Sep 13, 2012
Project Member #9 julien.r...@gmail.com
Trying to be smart would defeat the purpose of match, I think.
Sep 13, 2012
Project Member #10 asmeurer@gmail.com
I think the real answer is the same as with subs: we really need both.
Nov 25, 2012
Project Member #11 smi...@gmail.com
https://github.com/sympy/sympy/pull/1673

def test_issue_784():
    mu, gamma, x = symbols('mu gamma x')
    f = (- gamma * (x-mu)**2 - log(gamma) + log(2*pi)) / 2
    g1 = Wild('g1', exclude=[gamma])
    g2 = Wild('g2', exclude=[gamma])
    g3 = Wild('g3', exclude=[gamma])
    assert f.expand().match(g1 * log(gamma) + g2 * gamma + g3) == \
    {g3: log(2)/2 + log(pi)/2, g1: -S(1)/2, g2: -mu**2/2 + mu*x - x**2/2}
Labels: NeedsReview smichr
Dec 6, 2012
Project Member #12 smi...@gmail.com
(No comment was entered for this change.)
Status: Fixed
Mar 5, 2014
Project Member #13 asmeurer@gmail.com
We have moved issues to GitHub https://github.com/sympy/sympy/issues. 
Labels: Restrict-AddIssueComment-Commit
Apr 5, 2014
Project Member #14 skirpic...@gmail.com
Migrated to http://github.com/sympy/sympy/issues/3883
Sign in to add a comment

Powered by Google Project Hosting