SciML / MultiScaleArrays.jl

A framework for developing multi-scale arrays for use in scientific machine learning (SciML) simulations
https://docs.sciml.ai/MultiScaleArrays/stable/
Other
74 stars 16 forks source link

MethodError: Base.Broadcast.promote_containertype #24

Closed HugoMH closed 6 years ago

HugoMH commented 7 years ago

While solving an ODEProblem, defined with a MultiScaleArrays I got this error message:

prob = ODEProblem(f, A_MultiScaleArrays, tspan) solve(prob)

ERROR: MethodError: Base.Broadcast.promote_containertype(::Type{Container{Environment{MultiScaleArrays.AbstractMultiScaleArrayLeafWithInfofields{Float64},Float64},Float64}}, ::Type{Container{MultiScaleArrays.AbstractMultiScaleArray{Float64},Float64}}) is ambiguous. Candidates:
promote_containertype(::Type{S}, ::Type{T}) where {T<:MultiScaleArrays.AbstractMultiScaleArray, S<:AbstractArray} in MultiScaleArrays at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:11
promote_containertype(::Type{#s2} where #s2, ::Type{T}) where T<:MultiScaleArrays.AbstractMultiScaleArray in MultiScaleArrays at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:13
promote_containertype(::Type{T}, ::Type{S}) where {T<:MultiScaleArrays.AbstractMultiScaleArray, S<:AbstractArray} in MultiScaleArrays at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:10
Possible fix, define
promote_containertype(::Type{T<:MultiScaleArrays.AbstractMultiScaleArray}, ::Type{S<:MultiScaleArrays.AbstractMultiScaleArray})

I thus added Base.Broadcast.promote_containertype(::Type{T}, ::Type{S}) where {T<:AMSA, S<:AMSA} = T Base.Broadcast.promote_containertype(::Type{S}, ::Type{T}) where {T<:AMSA, S<:AMSA} = T to math.jl

Then I did reload("MultiScaleArrays") and got INFO: Recompiling stale cache file /home/hmh/.julia/lib/v0.6/MultiScaleArrays.ji for module MultiScaleArrays. WARNING: Method definition promote_containertype(Type{S<:(MultiScaleArrays.AbstractMultiScaleArray{B} where B)}, Type{T<:(MultiScaleArrays.AbstractMultiScaleArray{B} where B)}) in module MultiScaleArrays at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:14 overwritten at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:15. WARNING: Method definition promote_containertype(Type{S<:(MultiScaleArrays.AbstractMultiScaleArray{B} where B)}, Type{T<:(MultiScaleArrays.AbstractMultiScaleArray{B} where B)}) in module MultiScaleArrays at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:14 overwritten at /home/hmh/.julia/v0.6/MultiScaleArrays/src/math.jl:15. WARNING: replacing module MultiScaleArrays.

Then, it works, but I don't know why, and I hope it's right. cheers hugo

ChrisRackauckas commented 7 years ago

I think this has more to do with https://github.com/JuliaDiffEq/MultiScaleArrays.jl/issues/22 and the type that's coming out of similar. I'll take a look at this.

ChrisRackauckas commented 6 years ago

This was fixed by fixing #22. The issue was that AbstractMultiScaleArrays were changing into different types because they chopped off the extra arguments sometimes. By fixing that, this is no longer an issue and shouldn't ever show up (if it does, it is an error).