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

All monomial for free standard graded modules #2894

Conversation

HechtiDerLachs
Copy link
Collaborator

As discussed with @jankoboehm : An iterator over all monomials in standard graded free modules. To be used as a backend for eventual implementations of vector_space and friends. For the non-standard-graded case we will need other functionality, but this is not a contradiction. Nothing is exported and what is added fits with the work by @joschmitt .

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #2894 (c9b06df) into master (f8049ce) will decrease coverage by 0.01%.
The diff coverage is 73.33%.

@@            Coverage Diff             @@
##           master    #2894      +/-   ##
==========================================
- Coverage   80.39%   80.39%   -0.01%     
==========================================
  Files         456      457       +1     
  Lines       65235    65295      +60     
==========================================
+ Hits        52447    52491      +44     
- Misses      12788    12804      +16     
Files Coverage Δ
experimental/Schemes/Auxiliary.jl 93.36% <ø> (ø)
src/Modules/Iterators.jl 73.33% <73.33%> (ø)

Copy link
Member

@joschmitt joschmitt left a comment

Choose a reason for hiding this comment

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

Looks good to me, I left some minor comments.

@@ -6,3 +6,6 @@ include("primary_invariants.jl")
include("secondary_invariants.jl")
include("fundamental_invariants.jl")
include("affine_algebra.jl")

# postponed inclusion from src/Modules/Modules.jl due to dependency
include("../Modules/Iterators.jl")
Copy link
Member

Choose a reason for hiding this comment

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

This is not really about this PR, but it seems to me like we should start thinking about putting all types ((mutable) structs) in a handful of 'central' places or at least make sure that they can be included at first.

Although in this case we could also just move the all_monomials for rings to the Rings/ directory where it arguably belongs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this discussion has to take place at some point. But not here, eventually.

for i in 1:r
d_loc = d - Int(degree(F[i])[1])
d_loc < 0 && continue
result = result + length(all_monomials(R, d_loc))
Copy link
Member

Choose a reason for hiding this comment

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

One should be aware that all_monomials completely ignores the grading of a MPolyDecRing. But you only consider the standard graded case, so it's fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly.

src/Modules/Iterators.jl Outdated Show resolved Hide resolved
src/Modules/Iterators.jl Outdated Show resolved Hide resolved

mon_it = all_monomials(R, d_loc)
res = iterate(mon_it, nothing)
res === nothing && i == ngens(F) && return nothing
Copy link
Member

Choose a reason for hiding this comment

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

Can res === nothing happen? mon_it is an iterator over a component of non-negative degree, so there should always be at least one monomial, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know. Probably not. But the line doesn't hurt.

Copy link
Member

Choose a reason for hiding this comment

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

But what does happen if res === nothing and i != ngens(F), so the return nothing is not reached?
In the next line, you assign x, s = res which throws an error.
Handling this case properly (increase i etc.) might be possible, but doesn't seem to be worth the effort.

Suggested change
res === nothing && i == ngens(F) && return nothing
@assert res !== nothing

Maybe this would be clearer then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you might be right. But I don't want to interrupt the tests again now. Let's first see whether they pass in principle. In either case, the line doesn't seem to be breaking things. Worst case it's confusing to the reader.


mon_it = all_monomials(R, d_loc)
res_loc = iterate(mon_it, nothing)
res_loc === nothing && i == ngens(F) && return nothing
Copy link
Member

Choose a reason for hiding this comment

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

As above.

HechtiDerLachs and others added 2 commits October 11, 2023 15:55
Co-authored-by: Johannes Schmitt <jschmitt@posteo.eu>
Co-authored-by: Johannes Schmitt <jschmitt@posteo.eu>
@HechtiDerLachs
Copy link
Collaborator Author

From my side this is good to be merged. In my opinion, the small change discussed above is not worth spending the time and (electric) energy to running all the tests again.

Comment on lines +1179 to +1190
@testset "all_monomials for graded free modules" begin
R, (x, y, u, v, w) = QQ[:x, :y, :u, :v, :w]
S, (x, y, u, v, w) = grade(R)

F = graded_free_module(S, [-1, 2])

for d in -4:4
amm = Oscar.all_monomials(F, d)
@test d < -1 || !isempty(amm)
@test all(x->degree(x) == grading_group(F)([d]), amm)
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this identical test in ModulesGraded.jl and in GradedModules.jl?
(By the way, is the latter filename the result of a mishap or intentional?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put the tests in one file and ran it locally. Tests failed completely, but not due to the part I added. I suppose that test-file was deprecated, but not removed. Just to be sure, I then put my tests in both, finally. Somebody should tell us what's up with the test files, though.

Copy link
Collaborator

@afkafkafk13 afkafkafk13 left a comment

Choose a reason for hiding this comment

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

For me, this is good to go. My comment was not meant as blocking.

@afkafkafk13 afkafkafk13 merged commit 223c302 into oscar-system:master Oct 20, 2023
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants