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

allow == for two groups/group elements in fewer cases #4196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ThomasBreuer
Copy link
Member

@ThomasBreuer ThomasBreuer commented Oct 11, 2024

If _check_compatible for the two groups in question returns false then throw an exception.
Note that the result is not based only on the types of the arguments but also on the groups.

This addresses one of the questions from #4191.

If `_check_compatible` for the two groups in question returns `false`
then throw an exception.
Note that the result is not based only on the types of the arguments
but also on the groups.
@@ -372,9 +372,26 @@ end

Base.:*(x::GAPGroupElem, y::GAPGroupElem) = _prod(x, y)

==(x::GAPGroup, y::GAPGroup) = GapObj(x) == GapObj(y)
function ==(x::GAPGroup, y::GAPGroup)
_check_compatible(x, y; error = false) || throw(ArgumentError("x and y are not compatible"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_check_compatible(x, y; error = false) || throw(ArgumentError("x and y are not compatible"))
_check_compatible(x, y; error = true)

wouldn't this be easier? (similar below)
I don't see a reason to first suppress an error and then throw basically the same one right afterwards

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do not get a better error message in this case.

Comment on lines +389 to +394
# For two `GAPGroupElem`s,
# if no specialized method is applicable then no `==` comparison is allowed.
function ==(x::GAPGroupElem, y::GAPGroupElem)
_check_compatible(parent(x), parent(y); error = false) || throw(ArgumentError("parents of x and y are not compatible"))
throw(ArgumentError("== is not implemented for the given types"))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once Nemocas/AbstractAlgebra.jl#1853 is available, this method can be removed. maybe add this as a comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point of view is:
If the compatibility check returns false then we are sure that the question for == is not allowed,
but if the compatibility check returns true then likely there is a new subtype of GAPGroupElem for which a == method should be provided.
(Currently we have just the subtypes BasicGAPGroupElem and MatrixGroupElem.)

# For two `GAPGroupElem`s,
# if no specialized method is applicable then no `==` comparison is allowed.
function ==(x::GAPGroupElem, y::GAPGroupElem)
_check_compatible(parent(x), parent(y); error = false) || throw(ArgumentError("parents of x and y are not compatible"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants