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

Distributions.jl and RecursiveArrayTools.jl do not work together. #1878

Open
Nimrais opened this issue Jul 23, 2024 · 0 comments · May be fixed by #1908
Open

Distributions.jl and RecursiveArrayTools.jl do not work together. #1878

Nimrais opened this issue Jul 23, 2024 · 0 comments · May be fixed by #1908

Comments

@Nimrais
Copy link

Nimrais commented Jul 23, 2024

Hi! Thanks for this great package.

When I am training to construct a Categorical Distribution with an ArrayPartition vector it fails with a conversion error.

using RecursiveArrayTools
using Distributions

Categorical(ArrayPartition([1/3, 1/3], [1/3]))

Error

ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}

Closest candidates are:
  convert(::Type{ArrayPartition{T, S}}, ::ArrayPartition{<:Any, <:Tuple{Vararg{Any, N}}}) where {N, T, S<:Tuple{Vararg{Any, N}}}
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/K1bCr/src/array_partition.jl:543
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{T}, ::T) where T<:AbstractArray
   @ Base abstractarray.jl:16
  ...

Stacktrace:
 [1] Categorical{Float64, ArrayPartition{…}}(xs::Base.OneTo{Int64}, ps::ArrayPartition{Float64, Tuple{…}}; check_args::Bool)
   @ Distributions ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/discretenonparametric.jl:34
 [2] DiscreteNonParametric
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/discretenonparametric.jl:24 [inlined]
 [3] #_#115
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:31 [inlined]
 [4] DiscreteNonParametric
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:29 [inlined]
 [5] (Categorical{P} where P<:Real)(p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}})
   @ Distributions ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:34
 [6] top-level scope
   @ ~/repos/ReactiveBayes/ExponentialFamily.jl/categorical_bug.jl:4
Some type information was truncated. Use `show(err)` to see complete types.

ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}

Closest candidates are:
  convert(::Type{ArrayPartition{T, S}}, ::ArrayPartition{<:Any, <:Tuple{Vararg{Any, N}}}) where {N, T, S<:Tuple{Vararg{Any, N}}}
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/K1bCr/src/array_partition.jl:543
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{T}, ::T) where T<:AbstractArray
   @ Base abstractarray.jl:16
  ...

Stacktrace:
 [1] Categorical{Float64, ArrayPartition{…}}(xs::Base.OneTo{Int64}, ps::ArrayPartition{Float64, Tuple{…}}; check_args::Bool)
   @ Distributions ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/discretenonparametric.jl:34
 [2] DiscreteNonParametric
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/discretenonparametric.jl:24 [inlined]
 [3] #_#115
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:31 [inlined]
 [4] DiscreteNonParametric
   @ ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:29 [inlined]
 [5] (Categorical{P} where P<:Real)(p::ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}})
   @ Distributions ~/.julia/packages/Distributions/ji8PW/src/univariate/discrete/categorical.jl:34
 [6] top-level scope
   @ ~/repos/ReactiveBayes/ExponentialFamily.jl/categorical_bug.jl:4
Some type information was truncated. Use `show(err)` to see complete types.

Distributions v0.25.109
RecursiveArrayTools v3.26.0

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 a pull request may close this issue.

1 participant