Skip to content

Distances.pairwise fails on TrackedArray #59

@marekdedic

Description

@marekdedic
julia> using Distances, Flux

julia> pairwise(SqEuclidean(), param([1 2; 3 4]), dims = 2)
ERROR: MethodError: no method matching Float64(::Tracker.TrackedReal{Float64})
Closest candidates are:
  Float64(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:194
  Float64(::T<:Number) where T<:Number at boot.jl:718
  Float64(::Int8) at float.jl:60
  ...
Stacktrace:
 [1] convert(::Type{Float64}, ::Tracker.TrackedReal{Float64}) at ./number.jl:7
 [2] setindex!(::Array{Float64,1}, ::Tracker.TrackedReal{Float64}, ::Int64) at ./array.jl:766
 [3] sumsq_percol(::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/common.jl:107
 [4] _pairwise!(::Array{Tracker.TrackedReal{Float64},2}, ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/metrics.jl:600
 [5] #pairwise!#2(::Int64, ::typeof(pairwise!), ::Array{Tracker.TrackedReal{Float64},2}, ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/generic.jl:184
 [6] #pairwise! at ./none:0 [inlined]
 [7] #pairwise#4(::Int64, ::typeof(pairwise), ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/generic.jl:213
 [8] (::getfield(Distances, Symbol("#kw##pairwise")))(::NamedTuple{(:dims,),Tuple{Int64}}, ::typeof(pairwise), ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at ./none:0
 [9] top-level scope at REPL[2]:1

Could you please make it work? I think the problem is here, but I don't know how to fix it (probably needs to be done in Distances.jl?)

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions