Change or split ==, isequal and prmote taking MatrixElem arguments#2280
Change or split ==, isequal and prmote taking MatrixElem arguments#2280JohnAAbbott wants to merge 10 commits intoNemocas:masterfrom
==, isequal and prmote taking MatrixElem arguments#2280Conversation
|
On Fri, Jan 09, 2026 at 07:18:02AM -0800, Max Horn wrote:
@fingolfin commented on this pull request.
> +function canonical_unit(a::MatElem{T}) where T <: NCRingElement
+ @Req (nrows(a) > 0 && ncols(a) > 0) "Matrix must contain at least one entry"
+ return canonical_unit(a[1, 1])
+end
```suggestion
canonical_unit(a::MatElem) = canonical_unit(matrix(a))
```
a[1,1] was wrong anyway, it should be the 1st (in some fixed ordering)
non-zero entry of a
… --
Reply to this email directly or view it on GitHub:
#2280 (review)
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
|
I marked several of @fingolfin suggestions as resolved because I already had some of the changes in my local copy. The latest push should resolve all of them. |
|
Test fails: I think it is comparing a I'd be OK with either, but |
|
One failing test: in
|
The equality test being called is likely unintentional: It calls |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2280 +/- ##
==========================================
- Coverage 88.15% 88.11% -0.05%
==========================================
Files 126 126
Lines 31999 32038 +39
==========================================
+ Hits 28210 28231 +21
- Misses 3789 3807 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I have added new equality test functions (just the I had wanted to use How often does it arise that one wants to know if a matrix is a scalar multiple of a truncated identity matrix? We already have tests for |
MatrixElem argument
Personally I agree, and I'd be supportive of efforts trying to change that, but:
|
Ahhh! That's a fair point. |
|
To make the tests pass I disabled two checks because they triggered the ambiguity error. Shall I leave them commented out? |
|
Here's another surprise. I wanted to increase code coverage (to keep GitHub happy), and discovered that when To clarify: in |
The functions in |
| @test S(m) == m | ||
| @test m == S(m) | ||
| # @test S(m) == m | ||
| # @test m == S(m) |
There was a problem hiding this comment.
These should either work or (if they are logical nonsense) be removed. Just commenting out is bad.
There was a problem hiding this comment.
They do currently work, but the point I wanted to make earlier is whether we really want to guarantee that they will work evermore. I think we should not make this guarantee, and @fingolfin wrote Personally I agree. So based on that comment I shall delete these tests since they do not represent behaviour that we wish to guarantee in the future.
There was a problem hiding this comment.
@JohnAAbbott I think you misunderstood me here: I agree that we should work on removing this feature. But that's not done by just removing the test, or the code. Rather, we have to carefully do this, to avoid breaking people's code badly. To be explicitly:
- such a thing should never be done as an aside in PR that is focused on something else (where it will slip by the attention of people)
- rather, deprecating a feature should be done in its own dedicated PR, so that people can be aware of it
- it should be made sure that it is mentioned as a breaking change in the release notes (another reason why having it in its own PR is useful: we can then use our existing tooling and edit the PR title to be directly suitable for inclusion in the release notes)
- the change should be done in a way that minimizes "hidden" breakage. In the case at hand, this means that it would be OK from "comparison works in a sensible way" to "comparison raises an helpful error. It would not be OK to go to "comparison suddenly always returns false" or "comparison raises an unhelpful error".
- this change then of course would have to be reflected in the tests -- but not by just removing a test, but by replacing it with a test that verifies the new property (e.g. "always raises helpful error") actually holds
My points 1+2 also apply to other "unrelated" changes. This is why e.g. I said the change to how empty matrices are printed should not be discussed via a code comment inserted here, but in a separate issue; and be resolved in a separate PR, dedicated to that.
If juggling multiple git branches is a hold-up factor here, I'd be happy to sit with you to discuss some ways how you can manage multiple active git branches with low friction.
817d71c to
b0bfdaa
Compare
|
I have marked this as Ready for review because the CI checks all pass. Note that passing was achieved by disabling a whole test-set in |
|
I have just created issue #2299 to discuss the issue related to equality testing. If the change there is approved then the implementation will be in a separate PR. |
|
I have found a minimal diff that preserves the current behavior (which I'll commit here in a minute). This does not intend to force a decision on #2299, but it allows for this PR to continue on in a non-breaking way. |
…ctAlgebra.jl into JAA/split-MatrixElem1
|
The tests are failing, though: |
Co-authored-by: Max Horn <max@quendi.de>
@lgoettgens reinstated a block of tests which I had deleted (because I believe they no longer represent behaviour that we wish to guarantee). Shall I wait for @lgoettgens to fix this? |
Indeed, but this is a newly added test that's failing now (rather than removing an already existing test). And this new test does not work on current master as well (although with a different error) |
|
I would prefer if this rather large PR would only do rather mechanical changes that don't change any behavior. The behavior change should IMO be in a smaller follow-up PR once #2299 is decided on |
But why reinstate the test? |
I don't see it as "reinstating" but as "not removing in the first place". Since this PR here is supposed to be non-breaking (assuming we move the breaking parts to a follow-up after #2299), it should not remove any tests. As in that case, we cannot be sure that it indeed is non-breaking. |
Most irritating! Have a good weekend |
|
I shall let @lgoettgens take over this PR from now on. |
As a first step, I cherry-picked the (in my opinion) uncontroversial changes into the new PR #2302. Once that is in, I'll rebase this one here to then have something smaller to reason about. If I am not mistaken, there should be only |
| one(a::MatElem{T}) where T <: NCRingElement | ||
| one(a::MatRingElem{T}) where T <: NCRingElement |
There was a problem hiding this comment.
I've thought about this back and forth: should we list both MatElem and MatRingElem in these docstrings, or just MatElem?
Right now I tend towards "only list MatElem": these are matrix APIs, and they should be documented as such.
All the MatRingElem ones should be handled by a catch-all section in the MatRing documentation, i.e., in docs/src/matrix_algebras.md. Indeed, we already say this:
Almost all of the functionality specified for generic matrices is available for matrix
algebras. The exceptions are functions such assolveandnullspacewhich may
return non-square matrices, or which don't accept square matrices.
Thus:
| one(a::MatElem{T}) where T <: NCRingElement | |
| one(a::MatRingElem{T}) where T <: NCRingElement | |
| one(a::MatElem{T}) where T <: NCRingElement |
| one(a::MatRingElem{T}) where T <: NCRingElement | ||
|
|
||
| Return the identity matrix in the same matrix space as $a$. | ||
| Return the identity matrix in the same matrix space or matrix ring as $a$. |
There was a problem hiding this comment.
| Return the identity matrix in the same matrix space or matrix ring as $a$. | |
| Return the identity matrix in the same matrix space as $a$. |
|
|
||
| @doc raw""" | ||
| one(a::MatrixElem{T}) where T <: NCRingElement | ||
| one(a::MatElem{T}) where T <: NCRingElement |
There was a problem hiding this comment.
This line could be merged right away
|
|
||
| """ | ||
| is_symmetric(M::MatrixElem) | ||
| is_symmetric(M::MatElem) |
|
|
||
| Return whether the form corresponding to the matrix `M` is alternating, | ||
| i.e. `M = -transpose(M)` and `M` has zeros on the diagonal. | ||
| i.e. `M == -transpose(M)` and `M` has zeros on the diagonal. |
MatrixElem argument==, isequal and prmote taking MatrixElem arguments
First phase of splitting functions which take
MatrixElem