Hi,

I had some code like

    if isa(spec, Symbol)
      A[i,spec] = 1
    elseif isa(spec, Vector{(Symbol,Float64)})
      @assert(isapprox(sum(map(x -> x[2],spec)),1))
      for (obs,prob) = spec
        A[i,obs] = prob
      end
    else
      error("don't know how to parse $spec for aggregation")
    end

but got bittenby a spec = [(:I,0),(:U,1)] which is valid for my problem,
so I realized I need to test for Real, not Float64.

If this was a method of a generic fuction, I could simply use T <: Real
and then use Vector{(Symbol,T)} in the type signature --- but it isn't,
so I would be interested in how to test for the condition in the subject
line in an if branch.

isa(Vector{(Symbol,Real)}) won't work, my understanding is that this is
because of invariance.

Best,

Tamas

Reply via email to