Oscar.jl
Oscar.jl copied to clipboard
Promotion system for Galois fields not properly implemented?
When I was trying to implement the ring interface for Oscar, I stumbled upon the following oddity:
promote_rule(fmpz, Int)
gives fmpz
as expected. But
promote_rule(gfp_elem, Int)
returns Union{}
. That's not correct, is it?
This seems to be breaking my tests...
The gfp_elem type is defined in Nemo, so it should end up there. But if it is stalling your oscar tests, maybe put it in oscar with a TODO: move this to nemo
I'm trying to find the correct promote_rules to add, but I don't get through. So, it would be nice if someone could have a look at this with me or just provide the fix.
Tests just don't cover the Galois fields for now. But they should in the future.
Alright, now it seems I could fix it. Turns out that promotion for gfp_mpoly
was also not there, yet. The lines I need to add to make my tests run are
AbstractAlgebra.promote_rule(::Type{gfp_elem}, ::Type{fmpz}) = gfp_elem
AbstractAlgebra.promote_rule(::Type{gfp_mpoly}, ::Type{fmpz}) = gfp_mpoly
I could add them to my files with the TODO. But in any case: Could someone double check that these are the correct lines? For instance, I'm afraid, the promotion of Int64
is not covered by these, is it?
This looks good. I will add them to AA today. The Int/Integer
one would be
AbstractAlgebra.promote_rule(::Type{gfp_mpoly}, ::Type{<: Integer}) = gfp_mpoly
But you can add them here too and we sort things out later. This should not hold up your PR.
A variation of this still seems to be in play?
julia> Oscar.promote_rule(FqFieldElem, Int)
Union{}
julia> promote_rule(FqFieldElem, ZZRingElem)
Union{}
But I am not sure what exactly this breaks... ?
Also
julia> promote_rule(fpFieldElem, Int)
Union{}
etc.
@thofma says "all of these should be added". So we just have to find/assign someone to do it.
@thofma just naively volunteered (har har)
Oscar.promote_rule
is not what you want. It is working correctly with the correct function
julia> Nemo.promote_rule(FqFieldElem, Integer)
FqFieldElem
julia> Nemo.promote_rule(FqFieldElem, ZZRingElem)
FqFieldElem