surface fixes for mis-typed matrices; getindex for Series

This commit is contained in:
Thomas Breloff 2016-06-30 14:08:05 -04:00
parent 7e56d85b83
commit 120f861a27
3 changed files with 12 additions and 6 deletions

View File

@ -930,6 +930,10 @@ function Base.getindex(axis::Axis, k::Symbol)
end end
end end
function Base.getindex(series::Series, k::Symbol)
series.d[k]
end
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# update attr from an input dictionary # update attr from an input dictionary

View File

@ -159,16 +159,18 @@ function expand_extrema!(sp::Subplot, d::KW)
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
data = d[letter] data = d[letter]
axis = sp.attr[Symbol(letter, "axis")] axis = sp.attr[Symbol(letter, "axis")]
if eltype(data) <: Number if eltype(data) <: Number || (isa(data, Surface) && all(di -> isa(di, Number), data.surf))
expand_extrema!(axis, data) if !(eltype(data) <: Number)
elseif isa(data, Surface) && eltype(data.surf) <: Number # huh... must have been a mis-typed surface? lets swap it out
data = d[letter] = Surface(Matrix{Float64}(data.surf))
end
expand_extrema!(axis, data) expand_extrema!(axis, data)
elseif data != nothing elseif data != nothing
# TODO: need more here... gotta track the discrete reference value # TODO: need more here... gotta track the discrete reference value
# as well as any coord offset (think of boxplot shape coords... they all # as well as any coord offset (think of boxplot shape coords... they all
# correspond to the same x-value) # correspond to the same x-value)
# @show letter,eltype(data),typeof(data)
d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data) d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
expand_extrema!(axis, d[letter])
end end
end end

View File

@ -399,8 +399,8 @@ Base.Array(surf::Surface) = surf.surf
for f in (:length, :size) for f in (:length, :size)
@eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...) @eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...)
end end
Base.copy(surf::Surface) = Surface(copy(surf.surf)) Base.copy(surf::Surface) = Surface{typeof(surf.surf)}(copy(surf.surf))
Base.eltype(surf::Surface) = eltype(surf.surf) Base.eltype{T}(surf::Surface{T}) = eltype(T)
function expand_extrema!(a::Axis, surf::Surface) function expand_extrema!(a::Axis, surf::Surface)
ex = a[:extrema] ex = a[:extrema]