Keno / SIUnits.jl

Efficient unit-checked computation
Other
70 stars 26 forks source link

Plot Recipes #86

Open ChrisRackauckas opened 8 years ago

ChrisRackauckas commented 8 years ago

I think units should add plot recipes for the types. However, it's quite hard because it's hard to get the dispatch right. Here's what I tried:

@recipe f{T<:SIUnits.SIQuantity}(::Type{T}, x::T) = x.val # Works
#@recipe f{T<:SIUnits.SIQuantity{N,m,kg,s,A,K,mol,cd,rad,sr}}(::Type{SIUnits.SIQuantity{N,m,kg,s,A,K,mol,cd,rad,sr}},x::T)  map((y)->y.val,x) #Cannot compile
#@recipe f{T<:AbstractArray{SIUnits.SIQuantity}}(::Type{T}, unitArray::T) =  map((x)->x.val,unitArray) # Doesn't dispatch onto this because parametric array problems
@recipe f{T<:AbstractArray{SIUnits.SIQuantity{Float64,0,0,1,0,0,0,0,0,0}}}(::Type{T}, unitArray::T) =  (map((x)->x.val,unitArray)) # Works for seconds

This is related to tbreloff/Plots.jl#427