Skip to content

Commit

Permalink
Merge pull request #134 from yuyichao/0.4-binding
Browse files Browse the repository at this point in the history
Fix 0.4 deprecated bindings
  • Loading branch information
andreasnoack committed Sep 21, 2015
2 parents 3638f71 + b4f37c0 commit 340d32e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,8 @@ os:
- linux
- osx
julia:
- release
- 0.3
- 0.4
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion docs/source/scalarstats.rst
Expand Up @@ -191,7 +191,7 @@ Summary of Statistics

.. code-block:: julia
immutable SummaryStats{T<:FloatingPoint}
immutable SummaryStats{T<:AbstractFloat}
mean::T
min::T
q25::T
Expand Down
6 changes: 3 additions & 3 deletions src/common.jl
Expand Up @@ -18,11 +18,11 @@ typealias IntegerArray{T<:Integer,N} AbstractArray{T,N}
typealias IntegerVector{T<:Integer} AbstractArray{T,1}
typealias IntegerMatrix{T<:Integer} AbstractArray{T,2}

typealias RealFP Union(Float32, Float64)
@compat typealias RealFP Union{Float32, Float64}

## conversion from real to fp types

fptype{T<:Union(Float32,Bool,Int8,UInt8,Int16,UInt16)}(::Type{T}) = Float32
fptype{T<:Union(Float64,Int32,UInt32,Int64,UInt64,Int128,UInt128)}(::Type{T}) = Float64
@compat fptype{T<:Union{Float32,Bool,Int8,UInt8,Int16,UInt16}}(::Type{T}) = Float32
@compat fptype{T<:Union{Float64,Int32,UInt32,Int64,UInt64,Int128,UInt128}}(::Type{T}) = Float64
fptype(::Type{Complex64}) = Complex64
fptype(::Type{Complex128}) = Complex128
14 changes: 7 additions & 7 deletions src/deviation.jl
Expand Up @@ -32,7 +32,7 @@ function sqL2dist{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T})
length(b) == n || throw(DimensionMismatch("Input dimension mismatch"))
r = 0.0
for i = 1:n
@inbounds r += abs2(a[i] - b[i])
@inbounds r += abs2(a[i] - b[i])
end
return r
end
Expand All @@ -46,9 +46,9 @@ function L1dist{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T})
length(b) == n || throw(DimensionMismatch("Input dimension mismatch"))
r = 0.0
for i = 1:n
@inbounds r += abs(a[i] - b[i])
@inbounds r += abs(a[i] - b[i])
end
return r
return r
end

# Linf distance
Expand All @@ -57,16 +57,16 @@ function Linfdist{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T})
length(b) == n || throw(DimensionMismatch("Input dimension mismatch"))
r = 0.0
for i = 1:n
@inbounds v = abs(a[i] - b[i])
@inbounds v = abs(a[i] - b[i])
if r < v
r = v
end
end
return r
return r
end

# Generalized KL-divergence
function gkldiv{T<:FloatingPoint}(a::AbstractArray{T}, b::AbstractArray{T})
function gkldiv{T<:AbstractFloat}(a::AbstractArray{T}, b::AbstractArray{T})
n = length(a)
r = 0.0
for i = 1:n
Expand All @@ -91,7 +91,7 @@ maxad{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T}) = Linfdist(a, b)
msd{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T}) = sqL2dist(a, b) / length(a)

# RMSD: root mean squared deviation
function rmsd{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T}; normalize::Bool=false)
function rmsd{T<:Number}(a::AbstractArray{T}, b::AbstractArray{T}; normalize::Bool=false)
v = sqrt(msd(a, b))
if normalize
amin, amax = extrema(a)
Expand Down
2 changes: 1 addition & 1 deletion src/hist.jl
@@ -1,7 +1,7 @@
import Base: show, ==, push!, append!

## nice-valued ranges for histograms
function histrange{T<:FloatingPoint}(v::AbstractArray{T}, n::Integer, closed::Symbol)
function histrange{T<:AbstractFloat}(v::AbstractArray{T}, n::Integer, closed::Symbol)
if length(v) == 0
return 0.0:1.0:0.0
end
Expand Down
12 changes: 6 additions & 6 deletions src/scalarstats.jl
Expand Up @@ -240,21 +240,21 @@ function _zscore_chksize(X::AbstractArray, μ::AbstractArray, σ::AbstractArray)
end
end

function zscore!{ZT<:FloatingPoint,T<:Real}(Z::AbstractArray{ZT}, X::AbstractArray{T}, μ::Real, σ::Real)
function zscore!{ZT<:AbstractFloat,T<:Real}(Z::AbstractArray{ZT}, X::AbstractArray{T}, μ::Real, σ::Real)
size(Z) == size(X) || throw(DimensionMismatch("Z and X must have the same size."))
_zscore!(Z, X, μ, σ)
end

function zscore!{ZT<:FloatingPoint,T<:Real,U<:Real,S<:Real}(Z::AbstractArray{ZT}, X::AbstractArray{T},
function zscore!{ZT<:AbstractFloat,T<:Real,U<:Real,S<:Real}(Z::AbstractArray{ZT}, X::AbstractArray{T},
μ::AbstractArray{U}, σ::AbstractArray{S})
size(Z) == size(X) || throw(DimensionMismatch("Z and X must have the same size."))
_zscore_chksize(X, μ, σ)
_zscore!(Z, X, μ, σ)
end

zscore!{T<:FloatingPoint}(X::AbstractArray{T}, μ::Real, σ::Real) = _zscore!(X, X, μ, σ)
zscore!{T<:AbstractFloat}(X::AbstractArray{T}, μ::Real, σ::Real) = _zscore!(X, X, μ, σ)

zscore!{T<:FloatingPoint,U<:Real,S<:Real}(X::AbstractArray{T}, μ::AbstractArray{U}, σ::AbstractArray{S}) =
zscore!{T<:AbstractFloat,U<:Real,S<:Real}(X::AbstractArray{T}, μ::AbstractArray{U}, σ::AbstractArray{S}) =
(_zscore_chksize(X, μ, σ); _zscore!(X, X, μ, σ))

function zscore{T<:Real}(X::AbstractArray{T}, μ::Real, σ::Real)
Expand Down Expand Up @@ -337,7 +337,7 @@ end
#
#############################

immutable SummaryStats{T<:FloatingPoint}
immutable SummaryStats{T<:AbstractFloat}
mean::T
min::T
q25::T
Expand All @@ -349,7 +349,7 @@ end
function summarystats{T<:Real}(a::AbstractArray{T})
m = mean(a)
qs = quantile(a, [0.00, 0.25, 0.50, 0.75, 1.00])
R = typeof(convert(FloatingPoint, zero(T)))
R = typeof(convert(AbstractFloat, zero(T)))
SummaryStats{R}(
convert(R, m),
convert(R, qs[1]),
Expand Down

0 comments on commit 340d32e

Please sign in to comment.