mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-08-16 10:01:56 +02:00
fix AbstractAlgebra.promote_rules
This commit is contained in:
parent
5acdc4a16c
commit
c6b557080d
@ -143,10 +143,22 @@ end
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
Base.promote_rule(::Type{<:GroupRingElem{T}},::Type{T}) where T = GroupRingElem{T}
|
||||
AbstractAlgebra.promote_rule(::Type{GREl}, ::Type{T}) where {T<:RingElement, GREl<:GroupRingElem{T}} = GREl
|
||||
|
||||
function Base.promote_rule(::Type{<:GroupRingElem{T}}, ::Type{U}) where {T, U<:RingElement}
|
||||
return (promote_rule(T, U) == T ? GroupRingElem{T} : Union{})
|
||||
function AbstractAlgebra.promote_rule(
|
||||
::Type{<:GroupRingElem{T, GR}},
|
||||
::Type{<:GroupRingElem{S, GR}}) where {T<:RingElement, S<:RingElement, GR}
|
||||
R = AbstractAlgebra.promote_rule(T, S)
|
||||
return (R == Union{} ? Union{} : GroupRingElem{R, GR})
|
||||
end
|
||||
|
||||
function AbstractAlgebra.promote_rule(::Type{<:GroupRingElem{T, GR}}, ::Type{S}) where {T, GR, S<:RingElement}
|
||||
R = AbstractAlgebra.promote_rule(T, S)
|
||||
return (R == Union{} ? Union{} : GroupRingElem{R, GR})
|
||||
end
|
||||
|
||||
function AbstractAlgebra.promote_rule(u::Type{U}, x::Type{GREl}) where {T, GREl<:GroupRingElem{T}, U<:RingElement}
|
||||
return AbstractAlgebra.promote_rule(x, u)
|
||||
end
|
||||
|
||||
function Base.rand(RG::GroupRing, density=0.05, args...)
|
||||
|
@ -124,6 +124,7 @@ function test_unary_binary_ops(f,g)
|
||||
old_f, old_g = deepcopy(f), deepcopy(g)
|
||||
@test parent(-f) == parent(f)
|
||||
@test !(-f === f)
|
||||
@test f == old_f
|
||||
|
||||
@test f+g isa typeof(f)
|
||||
@test parent(f) == parent(f+g)
|
||||
@ -227,13 +228,18 @@ end
|
||||
function test_promote_rules(f,g)
|
||||
f,g = deepcopy(f), deepcopy(g)
|
||||
@testset "promote_rules" begin
|
||||
@test AbstractAlgebra.promote_rule(typeof(f), Int16) == typeof(f)
|
||||
|
||||
@test_broken AbstractAlgebra.promote_rule(typeof(f), Int16) == typeof(f)
|
||||
@test_broken promote_rule(typeof(f), BigInt) == typeof(f)
|
||||
|
||||
@test AbstractAlgebra.promote_rule(typeof(f), typeof(g)) == typeof(f)
|
||||
@test AbstractAlgebra.promote_rule(typeof(g), typeof(f)) == typeof(f)
|
||||
|
||||
if has_base_ring(parent(f))
|
||||
S = base_ring(parent(f))
|
||||
@test AbstractAlgebra.promote_rule(typeof(f), elem_type(S)) == typeof(f)
|
||||
@test AbstractAlgebra.promote_rule(elem_type(S), typeof(f)) == typeof(f)
|
||||
end
|
||||
# @test promote_rupe(typeof(f), BigInt) == typeof(f)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user