replace sizes

This commit is contained in:
Michael K. Borregaard 2017-09-02 21:51:54 +02:00
parent 55d634c17a
commit 2de85d3fd3
3 changed files with 9 additions and 8 deletions

View File

@ -983,7 +983,8 @@ convertLegendValue(v::AbstractArray) = map(convertLegendValue, v)
# anything else is returned as-is
function slice_arg(v::AMat, idx::Int)
c = mod1(idx, size(v,2))
size(v,1) == 1 ? v[1,c] : v[:,c]
m,n = indices(v)
size(v,1) == 1 ? v[first(m),n[c]] : v[:,n[c]]
end
slice_arg(wrapper::InputWrapper, idx) = wrapper.obj
slice_arg(v, idx) = v

View File

@ -472,10 +472,10 @@ end
# add the discrete value for each item. return the continuous values and the indices
function discrete_value!(axis::Axis, v::AMat)
n,m = size(v)
cmat = zeros(n,m)
discrete_indices = zeros(Int, n, m)
for i=1:n, j=1:m
n,m = indices(v)
cmat = zeros(v)
discrete_indices = similar(Array{Int}, n, m)
@inbounds for i=n, j=m
cmat[i,j], discrete_indices[i,j] = discrete_value!(axis, v[i,j])
end
cmat, discrete_indices

View File

@ -1291,8 +1291,8 @@ function gl_surface(x,y,z, kw_args)
if isa(x, AbstractMatrix) && isa(y, AbstractMatrix)
main = map(s->map(Float32, s), (x, y, z))
elseif isa(x, AbstractVector) || isa(y, AbstractVector)
x = Float32[x[i] for i = 1:size(z,1), j = 1:size(z,2)]
y = Float32[y[j] for i = 1:size(z,1), j = 1:size(z,2)]
x = Float32[x[i] for i = indices(z,1), j = indices(z,2)]
y = Float32[y[j] for i = indices(z,1), j = indices(z,2)]
main = (x, y, map(Float32, z))
else
error("surface: combination of types not supported: $(typeof(x)) $(typeof(y)) $(typeof(z))")
@ -1301,7 +1301,7 @@ function gl_surface(x,y,z, kw_args)
points = map(Point3f0, zip(vec(x), vec(y), vec(z)))
faces = Cuint[]
idx = (i,j) -> sub2ind(size(z), i, j) - 1
for i=1:size(z,1), j=1:size(z,2)
for i=indices(z,1), j=indices(z,2)
i < size(z,1) && push!(faces, idx(i, j), idx(i+1, j))
j < size(z,2) && push!(faces, idx(i, j), idx(i, j+1))