-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hep: Fixes bug in gamma_trace of sum of products containing GammaMatrix mixed with other symbols #23786
Conversation
… of GammaMatrix mixed with other factors.
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) Full benchmark results can be found as artifacts in GitHub Actions |
I don't know what to do about failing "test / optional-dependencies (3.11.0-alpha - 3.11, true) (pull_request)". It's completely unrelated to the change I made, and seems to be happening to everyone on all pull requests now. |
Yes, that's #23774. It's fine if that test fails. It is not "required" to pass. |
@@ -588,6 +588,8 @@ Gilbert Gede <[email protected]> <[email protected]> | |||
Gilles Schintgen <[email protected]> | |||
Gina <[email protected]> | |||
Gleb Siroki <[email protected]> | |||
Glenn Horton-Smith <[email protected]> | |||
Glenn Horton-Smith <[email protected]> Glenn Horton-Smith <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only the first of these lines is needed. It doesn't look like the ksu.edu
email is used in any of the commits. Did you add that because of an error reported by the mailmap script?
If you actually wanted your entry in the AUTHORS file to be recorded under ksu.edu
then it should be the other way around i.e.:
Glenn Horton-Smith <[email protected]> Glenn Horton-Smith <[email protected]>
That way it is saying that the gmail address is an alias for the ksu address which should be the one recorded in the AUTHORS file and associated with these commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed for any current commit. I can remove the second line if you like. I only did it because I have "email = [email protected]" as a global setting on my work computer and I thought it might be useful in case I ever made a commit from work without remembering to set the email correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is just which email address you would like to be recorded in AUTHORS. If you want it to be the gmail address then the above is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. Yes, I want it to be the gmail address. Thanks for asking.
@@ -399,3 +400,25 @@ def test_gamma_matrix_trace(): | |||
t = ps*ps*ps*ps*ps*ps*ps*ps | |||
r = gamma_trace(t) | |||
assert r.equals(4*p2*p2*p2*p2) | |||
|
|||
def test_bug_13636(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually there should be two blank lines between top-level functions, classes etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed now.
assert ta.equals( | ||
-16 * ki(i0) * ki(-i0) * pf(i1) * pi(-i1) | ||
+ 32 * ki(i0) * ki(i1) * pf(-i0) * pi(-i1) | ||
) | ||
assert tb.equals(-8 * x * ki(i0) * pf(-i0) * pi(i1) * pi(-i1)) | ||
assert t_a_plus_b.equals(ta + tb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ==
not work here or does it need to use .equals
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I just checked, and indeed == does not work here. The .equals() function for tensor objects applies sympify and .cannon_bp to the tensor expression before comparing, while .eq is just Basic.eq, and is false for this comparison because the expression trees are not exactly identical. The other test functions such as test_gamma_matrix_trace() also use .equals().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually it is better to construct the exact expression for comparison in tests so that they can be compared with ==
. Sometimes that is not be best option because the exact expression is confusing and does not display the intent of the test well.
I'm not sure what the preferred answer would be here. What exactly is the difference between the compared expressions? You can use srepr
as one way to view the expression structure explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ta == 4*((-4)*ki(L_0)*ki(-L_0)*pf(L_1)*pi(-L_1) + 8*ki(L_0)*ki(L_1)*pf(-L_0)*pi(-L_1))
which is the same as the expression being tested against except for distribution of the factor of 4 over the coefficients. I can use the exact expression for the test, I don't mind.
tb and ta_plus_tb are the same as the expressions they are being compared against, so we could use == there with no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed now.
I can't personally verify the correctness of the code or the test from a mathematical perspective. Maybe @jksuom, @sami-b95 or @certik can? If not then I'm happy to merge this but I'll wait to see if anyone can check it. This particular module is not maintained which makes it difficult to merge PRs. As far as I know none of the people who actively merge PRs has expert knowledge of either the module or the subject matter. @glenn-horton-smith if you are interested in maintaining/improving this then that would be very welcome. |
I think this is correct. All it is doing is a test to make sure the sum of traces is the same as trace of the sum. |
Thanks @certik. Could you also check #23823? I'll wait for @glenn-horton-smith to respond to my other comments but otherwise this is good to merge. |
Thanks @certik! |
Also some small whitespace changes for readability and style.
The pypy failure and the 3.11 failure are both unrelated to the changes here. |
Thanks @certik and @oscarbenjamin ! Have I missed responding to anything? |
Looks good to me. |
References to other Issues or PRs
Fixes #13636
Brief description of what is fixed or changed