ericphanson / UnbalancedOptimalTransport.jl

Sinkhorn divergences for measures of unequal mass
Other
14 stars 1 forks source link

Throw nicer error when `set = nothing` and cost matrix is not passed #7

Open ericphanson opened 4 years ago

ericphanson commented 4 years ago

The current error is pretty opaque about what the problem is:

julia> using UnbalancedOptimalTransport

julia> sinkhorn_divergence!(KL(1.0), DiscreteMeasure(rand(3)), DiscreteMeasure(rand(3)))
ERROR: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:603
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:603
  iterate(::ExponentialBackOff) at error.jl:253
  ...
Stacktrace:
 [1] _piterate at ./iterators.jl:963 [inlined]
 [2] iterate at ./iterators.jl:971 [inlined]
 [3] iterate at ./generator.jl:44 [inlined]
 [4] collect(::Base.Generator{Base.Iterators.ProductIterator{Tuple{Nothing,Nothing}},UnbalancedOptimalTransport.var"#30#31"{UnbalancedOptimalTransport.var"#18#19"}}) at ./array.jl:665
 [5] cost_matrix(::UnbalancedOptimalTransport.var"#18#19", ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/utilities.jl:40
 [6] unbalanced_sinkhorn!(::KL{1.0}, ::Function, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::Float64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/sinkhorn.jl:266
 [7] unbalanced_sinkhorn!(::KL{1.0}, ::Function, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::Float64) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/sinkhorn.jl:266
 [8] sinkhorn_divergence!(::KL{1.0}, ::Function, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::Float64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/optimized_methods.jl:25
 [9] sinkhorn_divergence!(::KL{1.0}, ::Function, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::Float64) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/optimized_methods.jl:22 (repeats 2 times)
 [10] sinkhorn_divergence!(::KL{1.0}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/sinkhorn.jl:252
 [11] sinkhorn_divergence!(::KL{1.0}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}, ::DiscreteMeasure{Array{Float64,1},Array{Float64,1},Nothing,Float64}) at /home/eric/.julia/packages/UnbalancedOptimalTransport/CdKnf/src/sinkhorn.jl:252
 [12] top-level scope at REPL[66]:1
 [13] eval(::Module, ::Any) at ./boot.jl:331
 [14] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [15] run_backend(::REPL.REPLBackend) at /home/eric/.julia/packages/Revise/Pcs5V/src/Revise.jl:1073
 [16] top-level scope at none:0
 [17] eval(::Module, ::Any) at ./boot.jl:331
 [18] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [19] run_backend(::REPL.REPLBackend) at /home/eric/.julia/packages/Revise/Pcs5V/src/Revise.jl:1073
 [20] top-level scope at none:0