-
Notifications
You must be signed in to change notification settings - Fork 126
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
Integrating JuLie into Oscar #1935
Conversation
Add testset wrappers.
Some polishing of docstrings
Add section on optional arguments for parents of return values.
Add first file for documentation.
Adjust indentation.
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 couple more comments.
I will shortly push several commits to this PR to address some of my own remarks. Please make sure to pull before (force) pushing anything to this PR / branch, to avoid loosing my changes
|
||
@Markdown.doc """ | ||
schensted(sigma::Vector{Integer}) | ||
schensted(sigma::Perm{T}) |
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.
Note that Perm{T}
is from AbstractAlgebra, but we don't use it in OSCAR -- we have our own permutation type here, PermGroupElem
That permutation type definitely should be supported here and in other places taking permutations. (To be clear: I am OK with supporting Perm{T}
, too, at least for now)
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 find it debatable whether a permutation really needs to be an element of a group. I feel there should be both (a permutation as an element of a group and a permutation just by itself) as separate types.
But again, such discussions should not stop any of the real work.
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.
Sure. And note that I did not ask for Perm{T}
support to be dropped, but rather for support for PermGroupElem
to be added, as that is the kind of permutation most OSCAR users will encounter.
But this is not a blocker for this PR.
This allows for two different entry points for the ring `P` of the output: | ||
Once as the first argument of a method of `characteristic_polynomial` with | ||
an extended signature, and second as an optional keyword argument for `ring` in | ||
the original method. This should be the general rule for such implementations |
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.
You are editing the OSCAR styleguide here. Either this is the general rule within OSCAR, or it isn't; the "should" makes no sense.
Whether this is the rule is debatable, though. Do we really want to force all code to offer both these variants? Why? I.e., why two ways to achieve the same thing?
Also, perhaps ring
is not always the best name for the argument, and from the text it sounds this is mandatory.
Indeed, as far as I can tell, the "real" charpoly
and minpoly
do not support the keyword argument variant.
My recommendation: move this addition to the styleguide into a separate PR (it doesn't really belong into this PR anyway). That way, we can discuss it there, and don't hold up this PR here.
|
||
|
||
@Markdown.doc """ | ||
conjugate(lambda::Partition{T}) where T<:IntegerUnion |
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 following is a purely informal remark, I don't expect you to do anything about it:
Note that in Julia (and OSCAR) this is normally called conj
. However, I've added a suggestion to #1826 that we should allow conjugate
as a synonym for conj
.
Long lines result in near useless diffs when editing them
If changing E.g. if the code really only makes sense for small inputs (e.g. my_factorial(n::T) where T <: IntegerUnion = my_factorial(T, Int(n))
function my_factorial(::Type{T}, n::Int) where T <: IntegerUnion
@req n >= 0 "n must be non-negative"
x = T(1)
for i in 1:n
x = mul!(x, x, i)
end
return x
end
Agreed |
julia> @btime partitions(Int8(90)); | ||
3.376 s (56634200 allocations: 6.24 GiB) | ||
|
||
julia> @btime ascending_partitions(Int8(90),alg="ks"); | ||
3.395 s (56634200 allocations: 6.24 GiB) | ||
|
||
julia> @btime ascending_partitions(Int8(90),alg="m"); | ||
3.451 s (56634200 allocations: 6.24 GiB) |
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.
Interesting! With which Julia version, OS and hardware did you obtain these benchmark results?
On my M1 MacBook with Julia 1.9.0-rc1, ascending_partitions
is actually twice as fast as partitions
:
julia> @btime partitions(Int8(90));
8.959 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="ks");
4.546 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="m");
4.616 s (56634195 allocations: 4.53 GiB)
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.
Oh! With Julia 1.8.5, it is much faster and looks more like your numbers:
julia> @btime partitions(Int8(90));
2.123 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="ks");
2.478 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="m");
2.432 s (56634195 allocations: 4.53 GiB)
So there seems to be a major performance regression in Julia 1.9 :-(. Wonder if we can pinpoint 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 weird. I believe my old benchmarks were done even with Julia 1.7.
sequence (which is our convention), one can also encode it as an *ascending* | ||
sequence. In the papers Kelleher & O'Sullivan (2014) and Merca (2012) it is | ||
said that generating the list of all ascending partitions is more efficient | ||
than generating descending ones. To test this, I have implemented the |
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 docstring uses "I" quite a bit: "I have", "I am", .... For an OSCAR user it won't be clear to whom that "I" refers. So we should rewrite it, either using "we"; or using "U. Thiel"
@ulthiel any preferences?
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.
Well, this was my personal documentation, so of course I used "I". I don't know. It's maybe also not so important.
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.
Noticing that the ascending_partitions stuff is in the pull request as well: I later changed this to ascending_compositions (which was part of my composition generator) because it's technically not a partition by definition. Since the composition stuff is currently not in the pull request (and not in JuLie) I'm unsure what should happen with this functionality. It should definitely be there eventually.
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.
Of course it made perfect sense to use "I" while this was in JuLie, and I am not criticizing this. I am merely pointing out that it doesn't make sense anymore in the context of Oscar, because most readers won't know whom "I" refers to. Moreover, it differs from the style we used elsewhere. Hence it should be changed. I can easily change it now, of course, but as a courtesy I thought I'd ask you for your preferences...?
Regarding your second reply: Note that this is the docstring for ascending_partitions
we are discussing here. So you are saying you renamed it later anyway, and moved it to some other module... So should we just delete it from this PR for now and it'll be added back later?
experimental/JuLie/partitions.jl
Outdated
|
||
|
||
@Markdown.doc """ | ||
partitions(m::IntegerUnion, n::IntegerUnion, l1::IntegerUnion, l2::IntegerUnion; z=0) |
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 type for z
here should match the declaration below
experimental/JuLie/partitions.jl
Outdated
|
||
The algorithm used is "parta" in [RJ76](@cite), de-gotoed from old ALGOL code by E. Thiel! | ||
""" | ||
function partitions(m::IntegerUnion, n::IntegerUnion, l1::IntegerUnion, l2::IntegerUnion; z::IntegerUnion=0) |
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.
If z
only allows for two choices, there is no point in allowing it to be IntegerUnion
, it can go back to being Int
.
However, why isn't this a Bool
with a speaking name? E.g.
function partitions(m::IntegerUnion, n::IntegerUnion, l1::IntegerUnion, l2::IntegerUnion; z::IntegerUnion=0) | |
function partitions(m::IntegerUnion, n::IntegerUnion, l1::IntegerUnion, l2::IntegerUnion; only_distinct_parts::Bool = false) |
julia> @btime partitions(Int8(90)); | ||
3.376 s (56634200 allocations: 6.24 GiB) | ||
|
||
julia> @btime ascending_partitions(Int8(90),alg="ks"); | ||
3.395 s (56634200 allocations: 6.24 GiB) | ||
|
||
julia> @btime ascending_partitions(Int8(90),alg="m"); | ||
3.451 s (56634200 allocations: 6.24 GiB) |
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.
Oh! With Julia 1.8.5, it is much faster and looks more like your numbers:
julia> @btime partitions(Int8(90));
2.123 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="ks");
2.478 s (56634195 allocations: 4.53 GiB)
julia> @btime ascending_partitions(Int8(90),alg="m");
2.432 s (56634195 allocations: 4.53 GiB)
So there seems to be a major performance regression in Julia 1.9 :-(. Wonder if we can pinpoint it...
It seems that the test (1.6, x64, ubuntu-latest) was killed only because some test cases took too long? If you agree, merge this PR now. And create a new issue to reduce the time for testing. At the end of the test output the biggest offenders are listed. Add them explicitly to the new issue. |
The tests of this PR are not slow, I already verified this. I already spent some effort last week to clean up this PR and fix a bunch of issues with it. It's unfortunate that nobody else really had timte to carefully review this code. The remaining blocker for me is the part where it changes the developer documentation. I will remove this now from the PR and adjust some more things. If someone wants to re-submit it in a separate PR, they are welcome, we can then discuss it there. |
Three files from JuLie are included: partitions, schur_polynomials, tableaux. Their tests and documentations are included too. We stopped importing partitions from Hecke. Right now there is a problem with
YoungTableau
, which uses partitions from AbstractAlgebra. For example,will create an error. This can be fixed by specifying
p = AbstractAlgebra.general.Partition([4,3,2])
. Eventually it would be nice to merge Tableau and YoungTableau.