-
Notifications
You must be signed in to change notification settings - Fork 133
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
Improve @perm
macro
#4490
Improve @perm
macro
#4490
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4490 +/- ##
==========================================
- Coverage 84.60% 84.54% -0.06%
==========================================
Files 672 672
Lines 88742 88907 +165
==========================================
+ Hits 75083 75170 +87
- Misses 13659 13737 +78
|
19de9a7
to
40fff71
Compare
Functionality is not changed yet
b80f625
to
81f7fa9
Compare
81f7fa9
to
0c1fa59
Compare
@fingolfin this now includes everything we discussed this afternoon |
|
||
ps = @perm [(1,2,3)(4,5), (6,2,3,1), (), (2,)(1,4)] | ||
@test ps isa Vector{PermGroupElem} | ||
@test allequal(parent, ps) |
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.
allequal
requires Julia >= 1.8 and we still run some of these tests in Julia 1.6.
Perhaps we should provide an allequal
implementation for older Julia versions?
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.
Isn't this what Compat.jl
is for? We already have it in the environment as a dependency of GAP.jl anyway. For the time being, I just import this one function in older julia versions.
(I don't understand why the 1.10 job succeeded, as the allequal
dispatch with predicate was only added right before the 1.11 feature freeze)
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 don't understand why the 1.10 job succeeded, as the
allequal
dispatch with predicate was only added right before the 1.11 feature freeze)
1.6 does not have allequal
at all and fails, 1.10 does have it and since we load Compat.jl
it adds that version to the existing function:
julia> allequal(
allequal(f, xs::Tuple) @ Compat ~/.julia/packages/Compat/gd6AI/src/Compat.jl:790
allequal(f, xs) @ Compat ~/.julia/packages/Compat/gd6AI/src/Compat.jl:789
allequal(r::AbstractRange) @ Base set.jl:537
allequal(c::Union{AbstractDict, AbstractSet}) @ Base set.jl:535
allequal(itr) @ Base set.jl:533
(this is julia 1.10 with Oscar master)
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.
Thanks for reminding me of JuliaLang/Compat.jl#814. This indeed resolves my confusion.
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.
Great! Some minor comments. Overall looks good.
src/Groups/perm.jl
Outdated
|
||
In the remaining case, the parent group is inferred to be the symmetric group | ||
with a degree of the highest integer referenced in `expr`. This may result in | ||
evalutating the expressions in the cycle entries multiple times, so it is |
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.
evalutating the expressions in the cycle entries multiple times, so it is | |
evaluating the expressions in the cycle entries multiple times, so it is |
OK for now, but we could avoid that, couldn't we? By storing the result of the evaluation immediately as vectors (of vectors), and then later e.g. passing those to cperm
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.
We can only avoid it for the case of a single permutation, and indeed the previous code did. I removed that for the time being to reduce Tha number of case distinctions.
For the vector and tuple cases, we cannot let the cperm dispatch handle the detection. Consider e.g. @perm [(1, 2), (3,4)]
. if we would delegate that to cperm([1, 2])
and cperm([3,4])
, then the parents would differ (Sym(2)
vs. Sym(4)
.
I have some ideas on how to avoid the double evaluation, but I need to think a bit more about it and test if it regressed performance for the case of just ints in all entries. Thus, I would like to move that to a follow-up PR
fde7973
to
dd9c60f
Compare
Resolves #3010.
@perm n+1 [....]
works now; the docstring always stated it would, but some macro hygiene thing messed up the use of local variables inside the degree expression.@perm G [(1,2,3,4)]
creates a list of perms with fixed parentG
.[@perm (1,2), @perm(3,4)]
and similar constructions (where julia infers weird scopes of things) now raise an explicit error.The release notes could include a compressed version of this list.