Skip to content

Commit

Permalink
Merge pull request #13 from Tchanders/deprecation-warnings
Browse files Browse the repository at this point in the history
Fix deprecated Array syntax
  • Loading branch information
tawheeler authored Jun 29, 2017
2 parents 2537806 + 66d05fa commit f983998
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/categorical_discretizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ supports_decoding{N,D}(cd::CategoricalDiscretizer{N,D}, d::D) = 1 ≤ d ≤ nlab
encode{N,D}(cd::CategoricalDiscretizer{N,D}, x::N) = cd.n2d[x]::D
encode{N,D}(cd::CategoricalDiscretizer{N,D}, x) = cd.n2d[convert(N,x)]::D
function encode{N,D}(cd::CategoricalDiscretizer{N,D}, data::AbstractArray)
arr = Array(D, length(data))
arr = Array{D}(length(data))
for (i,x) in enumerate(data)
arr[i] = encode(cd, x)
end
Expand All @@ -42,7 +42,7 @@ end
decode{N,D}(cd::CategoricalDiscretizer{N,D}, x::D) = cd.d2n[x]::N
decode{N,D}(cd::CategoricalDiscretizer{N,D}, x) = cd.d2n[convert(D,x)]::N
function decode{N,D}(cd::CategoricalDiscretizer{N,D}, data::AbstractArray{D})
arr = Array(N, length(data))
arr = Array{N}(length(data))
for (i,d) in enumerate(data)
arr[i] = decode(cd, d)
end
Expand Down
8 changes: 4 additions & 4 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function get_histogram_plot_arrays{R<:Real, I<:Integer}(binedges::Vector{R}, cou
n = length(binedges)
n == length(counts)+1 || error("binedges must have exactly one more entry than counts!")

arr_x = Array(R, n+1)
arr_x = Array{R}(n+1)
arr_x[1] = binedges[1]
arr_x[2:n+1] = binedges

arr_y = Array(I, n+1)
arr_y = Array{I}(n+1)
arr_y[1] = zero(I)
arr_y[2:n] = counts
arr_y[end] = zero(I)
Expand All @@ -41,11 +41,11 @@ function get_histogram_plot_arrays{R<:Real, F<:Real}(binedges::Vector{R}, pdfs::
n = length(binedges)
n == length(pdfs)+1 || error("binedges must have exactly one more entry than counts!")

arr_x = Array(R, n+1)
arr_x = Array{R}(n+1)
arr_x[1] = binedges[1]
arr_x[2:n+1] = binedges

arr_y = Array(F, n+1)
arr_y = Array{F}(n+1)
arr_y[1] = zero(F)
arr_y[2:n] = pdfs
arr_y[end] = zero(F)
Expand Down
4 changes: 2 additions & 2 deletions src/disc_uniformcount.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function binedges{N<:AbstractFloat}(alg::DiscretizeUniformCount, data::AbstractA

p = sortperm(data)
counts_per_bin, remainder = div(n,nbins), rem(n,nbins)
retval = Array(N, nbins+1)
retval = Array{N}(nbins+1)
retval[1] = data[p[1]]
retval[end] = data[p[end]]

Expand All @@ -36,7 +36,7 @@ function binedges{N<:Integer}(alg::DiscretizeUniformCount, data::AbstractArray{N

p = sortperm(data)
counts_per_bin, remainder = div(n,nbins), rem(n,nbins)
retval = Array(N, nbins+1)
retval = Array{N}(nbins+1)
retval[1] = data[p[1]]
retval[end] = data[p[end]]

Expand Down
4 changes: 2 additions & 2 deletions src/hybrid_discretizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function encode{N,D<:Integer}(disc::HybridDiscretizer{N,D}, x::N)
end
encode{N,D}(disc::HybridDiscretizer{N,D}, x) = encode(disc, convert(N, x))::D
function encode{N,D<:Integer}(disc::HybridDiscretizer{N,D}, data::AbstractArray)
arr = Array(D, length(data))
arr = Array{D}(length(data))
for (i,x) in enumerate(data)
arr[i] = encode(disc, x)
end
Expand All @@ -60,7 +60,7 @@ decode{N<:Real,D<:Integer,E<:Integer}(disc::HybridDiscretizer{N,D}, d::E, method
decode(disc, convert(D, d), method)

function decode{N,D<:Integer}(disc::HybridDiscretizer{N,D}, data::AbstractArray{D}, ::AbstractSampleMethod=SAMPLE_UNIFORM)
arr = Array(N, length(data))
arr = Array{N}(length(data))
for (i,d) in enumerate(data)
arr[i] = decode(disc, d)
end
Expand Down
6 changes: 3 additions & 3 deletions src/linear_discretizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function encode{N,D<:Integer}(ld::LinearDiscretizer{N,D}, x::N)
end
encode{N,D}(ld::LinearDiscretizer{N,D}, x) = encode(ld, convert(N, x))::D
function encode{N,D<:Integer}(ld::LinearDiscretizer{N,D}, data::AbstractArray)
arr = Array(D, length(data))
arr = Array{D}(length(data))
for (i,x) in enumerate(data)
arr[i] = encode(ld, x)
end
Expand Down Expand Up @@ -182,7 +182,7 @@ decode{N<:Real,D<:Integer,I<:Integer}(ld::LinearDiscretizer{N,D}, d::I, method::
decode(ld, convert(D,d), method)

function decode{N,D<:Integer}(ld::LinearDiscretizer{N,D}, data::AbstractArray{D}, ::AbstractSampleMethod=SAMPLE_UNIFORM)
arr = Array(N, length(data))
arr = Array{N}(length(data))
for (i,d) in enumerate(data)
arr[i] = decode(ld, d)
end
Expand Down Expand Up @@ -221,7 +221,7 @@ nlabels(ld::LinearDiscretizer) = ld.nbins
binedges(ld::LinearDiscretizer) = ld.binedges
bincenters{N<:AbstractFloat,D}(ld::LinearDiscretizer{N,D}) = (0.5*(ld.binedges[1:ld.nbins] + ld.binedges[2:end]))::Vector{Float64}
function bincenters{N<:Integer,D}(ld::LinearDiscretizer{N,D})
retval = Array(Float64, ld.nbins)
retval = Array{Float64}(ld.nbins)
for i = 1 : length(retval)-1
retval[i] = 0.5(ld.binedges[i+1]-1 + ld.binedges[i])
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_disc_MODL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class_value = [1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2];

#Case6
continuous = collect(1.0:1.0:100.0)
class_value = Array(Int64,100)
class_value = Array{Int64}(100)
for i in 1 : 100
class_value[i] = div((i-1),20)
end
Expand Down

0 comments on commit f983998

Please sign in to comment.