-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[WIP] Improve matrix slice #18298
base: master
Are you sure you want to change the base?
[WIP] Improve matrix slice #18298
Conversation
✅ Hi, I am the SymPy bot (v160). 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.7. 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.
|
fe49520
to
c048712
Compare
Is this still WIP? Does it fix #18411? |
I didn’t make up the patch for the issue yet. |
5832410
to
2f565ec
Compare
Codecov Report
@@ Coverage Diff @@
## master #18298 +/- ##
=============================================
+ Coverage 75.285% 75.333% +0.047%
=============================================
Files 635 639 +4
Lines 167071 167285 +214
Branches 39423 39465 +42
=============================================
+ Hits 125781 126021 +240
+ Misses 35748 35705 -43
- Partials 5542 5559 +17 |
One thing that makes it difficult to comprehend python >>> A = list(range(10))
>>> A[slice(None, None, -1)]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
>>> A[slice(None, None, -2)]
[9, 7, 5, 3, 1]
>>> A[slice(5, None, -1)]
[5, 4, 3, 2, 1, 0]
>>> A[slice(5, None, -2)]
[5, 3, 1] I think that it only applies for some case like |
I have decided to follow up the above definition |
Any updates on this? |
I accidentally started doing similar changes before I noticed this pull request :( It would be nice if this would also work for symbolic slices, for example:
Further, is there a reason why And finally, wouldn't it be better to call |
@sylee957 Any thoughts on #18298 (comment) |
References to other Issues or PRs
Brief description of what is fixed or changed
I have added
doit
for the following featuresIdentity of slicing
Block matrix slicing if no blocks are broken
Zero matrix, one matrix will be resized to an another zero matrix and one matrix
Slicing matrix symbol into an another matrix symbol with different dimensions
Slicing a permutation matrix into an another permutation matrix (Similar to slicing a block diagonal matrix into a block diagonal matrix)
Things that are work in progress are
Slicing a
FuncMatrix
into an anotherFuncMatrix
FuncMatrix
Slicing a block matrix while breaking some blocks.
block_collapse
rather than thedoit
.Also, I've added a rewriting method for
MatrixSlice
toMatrixPermute
, andMatrixPermute
toMatrixSlice
if the permutation is simply a reversing permutation.I have only implemented for the cases if the slicing specification are integers. But this can be improved later if there are some symbolic cases that can be logically reasonably sliced.
Other comments
This may have to be tested to cover up every cases, And I would try to implement some rewriting schemes from the
MatrixPermute
.Release Notes
MatrixSlice
.doit
forMatrixSlice
for canonicalization.