-
-
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
Matexpr: DiagonalMatrix and DiagonalOf enhancements #12459
Conversation
cf5dcaf
to
a1a336f
Compare
- added docstrings - shape of DiagonalMatrix matches underlying matrix shape (issue 12427) - updated _entry to detect out-of-square references - added size attribute to access the length of the diagonal - single-index indexing is relaxed to be allowed if the number of columns is known - updated the error messages regarding single-index indexing
Should the |
class DiagonalMatrix(MatrixExpr): | ||
"""DiagonalMatrix(M) will create a create a matrix expression that |
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 suppose, that something is wrong here: "will create a create a matrix"
class DiagonalOf(MatrixExpr): | ||
"""DiagonalOf(M) will create a create a matrix expression that |
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.
Here is the same: "will create a create a matrix"
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.
Got both changes and added "Examples" to the docstring and changed the name from size
to diagonal_length
.
|
@szymag , thanks for the review. Changes have been made as a new commit. |
Fixes #12427 and gives DiagonalOf and DiagonalMatrix docstrings that demonstrate how they behave.
A break from the previous behavior is that concrete indices are assumed to be smaller than symbolic ones and None is returned if the length of the diagonal cannot be determined. (Previously, the number of rows was always taken to be the length of the diagonal and the DiagonalMatrix was assumed to be square.)
Single-index indexing, e.g.
M[3]
is now allowed as long as the number of columns is known. This means that DiagonalOf can always be addressed wth a single index (since its number of columns is always 1).A couple of inconsequential edits of other files were made as they were noticed along the way.