Skip to content
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

Rewrite of non-commutative multiplication matching #17223

Merged
merged 8 commits into from Aug 2, 2019

Conversation

@anpandey
Copy link
Contributor

commented Jul 18, 2019

References to other Issues or PRs

Fixes #17172

Brief description of what is fixed or changed

Rewrites the matching code for non-commutative multiplication expressions that:

  • Respects expression structure (A*wmatchesA*B but notC*B)
  • Accounts for non-commutativity (A*B*w matches A*B*C but not B*A*C)
  • Enables non-commutative wildcards to match any subsequence (A*w*D matches A*B*C*D)

Release Notes

  • core
    • improvements to non-commutative matching

anpandey added some commits Jul 18, 2019

Rewrite of non-commutative matching
Rewrite of matching of non-commutative expressions that:
- Respects expression structure (A*w matches A*B but not C*B)
- Accounts for non-commutativity (A*B*w matches A*B*C but not B*A*C)
- Enables non-commutative wildcards to match any subsequence (A*w*D
  matches A*B*C*D)
@sympy-bot

This comment has been minimized.

Copy link

commented Jul 18, 2019

Hi, I am the SymPy bot (v147). 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.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

#### References to other Issues or PRs

Fixes #17172

#### Brief description of what is fixed or changed

Rewrites the matching code for non-commutative multiplication expressions that:

* Respects expression structure (`A*w`matches`A*B` but not`C*B`)
* Accounts for non-commutativity (`A*B*w` matches `A*B*C` but not `B*A*C`)
* Enables non-commutative wildcards to match any subsequence (`A*w*D` matches `A*B*C*D`)

#### Release Notes

<!-- BEGIN RELEASE NOTES -->
* core
  * improvements to non-commutative matching
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@certik

This comment has been minimized.

Copy link
Member

commented Jul 18, 2019

Does this have performance implications? I don't know if this method is used in the core or not.

@codecov

This comment has been minimized.

Copy link

commented Jul 18, 2019

Codecov Report

Merging #17223 into master will increase coverage by 0.069%.
The diff coverage is 98.85%.

@@              Coverage Diff              @@
##            master    #17223       +/-   ##
=============================================
+ Coverage   74.543%   74.612%   +0.069%     
=============================================
  Files          623       624        +1     
  Lines       161586    162077      +491     
  Branches     37925     38023       +98     
=============================================
+ Hits        120452    120930      +478     
+ Misses       35801     35793        -8     
- Partials      5333      5354       +21
@anpandey

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

I don't think it should affect the performance of anything else in the core. It seems like match is only every used for commutative arguments, in which case the performance should be identical.

@asmeurer

This comment has been minimized.

Copy link
Member

commented Jul 19, 2019

Great. How hard is it to now build matrix expression matching on top of this?

@anpandey

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

@asmeurer It should be enough to define the matrix wildcard class and its match method. The matching code in Mul itself should take care of everything else.

anpandey added some commits Jul 25, 2019

Check if matches contradict eachother
If a wildcard is more than once in a pattern, make sure that it matches
the same subexpression every time

@certik certik merged commit 2d05256 into sympy:master Aug 2, 2019

3 checks passed

codecov/project 74.612% (target 0%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
sympy-bot/release-notes The release notes look OK
Details
@certik

certik approved these changes Aug 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.