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

Matexpr: DiagonalMatrix and DiagonalOf enhancements #12459

Merged
merged 4 commits into from
Apr 1, 2017

Conversation

smichr
Copy link
Member

@smichr smichr commented Mar 30, 2017

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.

- 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
@smichr
Copy link
Member Author

smichr commented Mar 31, 2017

Should the size attribute be called diagonal_length?

class DiagonalMatrix(MatrixExpr):
"""DiagonalMatrix(M) will create a create a matrix expression that
Copy link
Contributor

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
Copy link
Contributor

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"

Copy link
Member Author

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
Copy link
Contributor

szymag commented Apr 1, 2017

Should the size attribute be called diagonal_length?

Size is not descriptive at all. In my opinion diagonal_length is much better.

@smichr
Copy link
Member Author

smichr commented Apr 1, 2017

@szymag , thanks for the review. Changes have been made as a new commit.

@smichr smichr merged commit eb57db8 into sympy:master Apr 1, 2017
@smichr smichr deleted the matexpr branch April 5, 2017 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants