-
Notifications
You must be signed in to change notification settings - Fork 72
Condense doc for is_square into single docstring #2186
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
Conversation
|
Bother! I meant to choose draft PR. Oh well... |
|
Just click on "Convert to draft"... |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2186 +/- ##
==========================================
+ Coverage 87.95% 88.00% +0.04%
==========================================
Files 127 127
Lines 31791 31769 -22
==========================================
- Hits 27961 27957 -4
+ Misses 3830 3812 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @doc raw""" | ||
| is_square(a::T) where {T <: NCRingElement} | ||
| is_square(M::MatElem) | ||
| is_square(M::MatRingElem) | ||
| There are two distinct situations: | ||
| (1) if the argument is matrix then check whether the matrix **shape** is square | ||
| (2) if the argument is not a matrix then check whether the **value** is a square (in the same ring) | ||
| """ | ||
| function is_square end |
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.
IMHO this really should be two docstrings:
- one for
is_square(a::NCRingElement) - one for
is_square(M::MatElem)
Both then can be included in different parts of the manual (one in the ring interface section, one in matrix interface section).
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.
ping @JohnAAbbott
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.
Apparently already done. I'll un-draft-ify the PR.
src/MatRing.jl
Outdated
| # See generic documentation in NCRings.jl | ||
| is_square(a::MatRingElem) = true |
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, but this is wrong now: according to what we discussed, MatRingElem are always square matrices "on the inside", but since they are NCRingElem, the meaning of is_square here now should be "is there some b such that b^2 == a ?", and that won't always be true.
So this needs to be removed, including the block comment mentioning is_square above it.
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 a bit confusing. Your suggestion is that for matrices (not of type MatRingElem) the function is_square checks the shape of the matrix. But if the matrix happens to be of type MatRingElem then is_square should behave differently? Well, of course, if one knows that the matrix is of type MatRingElem then there's no point in checking whether it is square...
So should is_square applied to a MatRingElem produce a not implemented error?
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.
A MatRingElem is not a matrix, i.e., not a MatElem (similar for MatrixGroupElem). Rather it is a NCRingElem. That was a major point in this discussion and explicitly discussed during the relevant triage discussion.
But "luckily" we have no general algorithm for computing square roots of matrices (I think) so by simply not implementing this method for MatRingElem all is well
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.
Function definition commented out and pushed. If the tests pass, I can delete the function definition.
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.
There's a catch! We have MatrixElem which is an alias for Union{MatElem, MatRingElem}. Then a method such as det(::MatrixElem) needs to check that its argument has square shape. What to do?
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 proper clean solution should be to resolve #1955.
Then det(::MatrixElem) can be changed into det(::MatElem), and a new method det(x::MatRingElem) = det(matrix(x)) can be added (where matrix(x::MatRingElem) returns the matrix wrapped by x).
src/AbsSeries.jl
Outdated
| return q | ||
| end | ||
|
|
||
| # See generic documentation in NCRings.jl |
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.
While I understand the intention, I note that we do not have such comments in front of the many other methods that implement ring interfaces, so it seems odd to have the comment added to just is_square. I'd rather not add this everywhere at all.
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.
OK - removed. Will push shortly.
Co-authored-by: Max Horn <max@quendi.de>
…ds has been eliminated
| ```@docs | ||
| Base.sqrt(::FracElem{T}) where {T <: RingElem} | ||
| ``` |
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.
By the looks of it, the same treatment should be extended to the Base.sqrt methods -- and then perhaps instead of removing the sections here outright, we could something like this:
| ```@docs | |
| Base.sqrt(::FracElem{T}) where {T <: RingElem} | |
| ``` | |
| Methods for `is_square` and `sqrt` are provided for inputs of type `FracElem`. |
fingolfin
left a comment
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.
Actually I just realized that is_square is now missing from the manual which also isn't good...
| @doc raw""" | ||
| is_square(a::T) where {T <: NCRingElement} | ||
| Return `true` iff `a` is the square of a value in its own ring. | ||
| See also `is_square(M::MatElem)` which tests whether a matrix has square shape. | ||
| """ | ||
| function is_square end |
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.
Actually, this docstring should be added to the manual. For now the "most obvious" spot would be in docs/src/ring_interface.md under "Optional functionality" (I am no fan of the current split between ring.md and ring_interface.md, I can never tell in which file to look -- but that should not matter here, we need to clean that up in a separate effort).
|
|
||
|
|
||
| @doc raw""" | ||
| is_square(a::T) where {T <: NCRingElement} |
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.
| is_square(a::T) where {T <: NCRingElement} | |
| is_square(a::NCRingElement) |
Of course this is a very minor complaint. But at least to me these function signatures are confusing, I always start wondering if there is a reason to write it with the type parameter. And I don't see a reason to write it this way in a docstring.
|
OK so the one missing thing here is that the docstring Afterwards we could merge it. And perhaps @varuntrehan7 could then make a similar PR to this one for |
|
So, slight change of plan: we'll merge this now, so that Varun can begin working on the |
i thought I had already made this into a draft PR