Skip to content

Commit

Permalink
Replace Integer field types with Int.
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-j-smith committed Jul 22, 2015
1 parent b0d8a91 commit 122db46
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions doc/examples/leuk.jl
Expand Up @@ -18,8 +18,8 @@ leuk = Dict{Symbol,Any}(
leuk[:N] = N = length(leuk[:t_obs])
leuk[:T] = T = length(leuk[:t]) - 1

leuk[:Y] = Array(Integer, N, T)
leuk[:dN] = Array(Integer, N, T)
leuk[:Y] = Array(Int, N, T)
leuk[:dN] = Array(Int, N, T)
for i in 1:N
for j in 1:T
leuk[:dN][i,j] = leuk[:fail][i] * (leuk[:t_obs][i] == leuk[:t][j])
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/rats.jl
Expand Up @@ -39,8 +39,8 @@ rats[:xbar] = mean(rats[:x])
rats[:N] = size(rats[:y], 1)
rats[:T] = size(rats[:y], 2)

rats[:rat] = Integer[div(i - 1, 5) + 1 for i in 1:150]
rats[:week] = Integer[(i - 1) % 5 + 1 for i in 1:150]
rats[:rat] = Int[div(i - 1, 5) + 1 for i in 1:150]
rats[:week] = Int[(i - 1) % 5 + 1 for i in 1:150]
rats[:X] = rats[:x][rats[:week]]
rats[:Xm] = rats[:X] - rats[:xbar]

Expand Down
6 changes: 3 additions & 3 deletions doc/images/mcmcUML.dot
Expand Up @@ -12,7 +12,7 @@ graph MCMC {

DenseArray [label = "{DenseArray}", pos="324,570"]

AbstractDependent [label = "{AbstractDependent|+ value\l+ symbol : Symbol\l+ nlink::Integer\l+ monitor : Vector\{Int\}\l+ eval : Function\l+ sources : Vector\{Symbol\}\l+ targets : Vector\{Symbol\}\l}", pos="275,425"]
AbstractDependent [label = "{AbstractDependent|+ value\l+ symbol : Symbol\l+ nlink::Int\l+ monitor : Vector\{Int\}\l+ eval : Function\l+ sources : Vector\{Symbol\}\l+ targets : Vector\{Symbol\}\l}", pos="275,425"]

AbstractLogical [label = "{AbstractLogical}", pos="75,425"]

Expand All @@ -32,11 +32,11 @@ graph MCMC {

ScalarVariate [label = "{ScalarVariate|+ value : Float64\l}", pos="275,665"]

Model [label = "{Model|+ nodes : Dict\{Symbol,Any\}\l+ dependents: Vector\{Symbol\}\l+ samplers : Vector\{Sampler\}\l+ states::Vector\{Vector\{Float64\}\}\l+ iter : Integer\l+ burnin : Integer\l+ chain : Integer\l+ hasinputs : Bool\l+ hasinits : Bool\l}", pos="275,290"]
Model [label = "{Model|+ nodes : Dict\{Symbol,Any\}\l+ dependents: Vector\{Symbol\}\l+ samplers : Vector\{Sampler\}\l+ states::Vector\{Vector\{Float64\}\}\l+ iter : Int\l+ burnin : Int\l+ chain : Int\l+ hasinputs : Bool\l+ hasinits : Bool\l}", pos="275,290"]

Sampler [label = "{Sampler|+ params : Vector\{Symbol\}\l+ eval : Function\l+ tune : Dict\{String,Any\}\l+ targets : Vector\{Symbol\}\l}", pos="495,290"]

AbstractChains [label = "{AbstractChains|+ value : Array\{Float64,3\}\l+ range : Range\{Int\}\l+ names : Vector\{String\}\l+ chains : Vector\{Integer\}\l}", pos="75,330"]
AbstractChains [label = "{AbstractChains|+ value : Array\{Float64,3\}\l+ range : Range\{Int\}\l+ names : Vector\{String\}\l+ chains : Vector\{Int\}\l}", pos="75,330"]

ModelChains [label = "{ModelChains|+ model : Model\l}", pos="75,250"]

Expand Down
Binary file modified doc/images/mcmcUML.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/mcmc/chains.rst
Expand Up @@ -470,7 +470,7 @@ Plotting

* ``c`` : sampler output to plot.
* ``ptype`` : plot type(s). Options are
* ``:autocor`` : autocorrelation plots, with optional argument ``maxlag::Integer=round(Integer, 10*log10(length(c.range)))`` determining the maximum autocorrelation lag to plot. Lags are plotted relative to the thinning interval of the output.
* ``:autocor`` : autocorrelation plots, with optional argument ``maxlag::Integer=round(Int, 10*log10(length(c.range)))`` determining the maximum autocorrelation lag to plot. Lags are plotted relative to the thinning interval of the output.
* ``:density`` : density plots. Optional argument ``trim::Tuple{Real,Real}=(.025,.975)`` trims off lower and upper quantiles of density.
* ``:mean`` : running mean plots.
* ``:trace`` : trace plots.
Expand Down
2 changes: 1 addition & 1 deletion doc/samplers/amm.rst
Expand Up @@ -81,7 +81,7 @@ Fields
``````
* ``adapt::Bool`` : whether the proposal distribution has been adaptively tuned.
* ``beta::Real`` : proportion of weight given to draws from the non-adaptive proposal with covariance factorization ``SigmaF``, relative to draws from the adaptively tuned proposal with covariance factorization ``SigmaLm``, during adaptive updating. Fixed at ``beta = 0.05``.
* ``m::Integer`` : number of adaptive update iterations that have been performed.
* ``m::Int`` : number of adaptive update iterations that have been performed.
* ``Mv::Vector{Float64}`` : running mean of draws ``v`` during adaptive updating. Used in the calculation of ``SigmaLm``.
* ``Mvv::Vector{Float64}`` : running mean of ``v * v'`` during adaptive updating. Used in the calculation of ``SigmaLm``.
* ``scale::Real`` : fixed value ``2.38^2`` in the factor (``scale / length(v)``) by which the adaptively updated covariance matrix is scaled---adopted from Gelman, Roberts, and Gilks :cite:`gelman:1996:EMJ`.
Expand Down
6 changes: 3 additions & 3 deletions doc/samplers/amwg.rst
Expand Up @@ -83,9 +83,9 @@ Fields
``````

* ``adapt::Bool`` : whether the proposal distribution has been adaptively tuned.
* ``accept::Vector{Integer}`` : number of accepted candidate draws generated for each element of the parameter vector during adaptive updating.
* ``batchsize::Integer`` : number of samples that must be accumulated before applying an adaptive update to the proposal distributions.
* ``m::Integer`` : number of adaptive update iterations that have been performed.
* ``accept::Vector{Int}`` : number of accepted candidate draws generated for each element of the parameter vector during adaptive updating.
* ``batchsize::Int`` : number of samples that must be accumulated before applying an adaptive update to the proposal distributions.
* ``m::Int`` : number of adaptive update iterations that have been performed.
* ``sigma::Vector{Float64}`` : updated values of the proposal standard deviations if ``adapt = true``, and the user-defined values otherwise.
* ``target::Real`` : target acceptance rate for the adaptive algorithm.

Expand Down
4 changes: 2 additions & 2 deletions doc/samplers/nuts.rst
Expand Up @@ -100,9 +100,9 @@ Fields
* ``gamma::Float64`` : dual averaging parameter, fixed at :math:`\gamma = 0.05`.
* ``Hbar::Float64`` : dual averaging parameter, defied as :math:`\bar{H}_m = \left(1 - \frac{1}{m + t_0}\right) \bar{H}_{m-1} + \frac{1}{m + t_0} \left(\text{target} - \frac{\alpha}{n_\alpha}\right)`.
* ``kappa::Float64`` : dual averaging parameter, fixed at :math:`\kappa = 0.05`.
* ``m::Integer`` : number of adaptive update iterations :math:`m` that have been performed.
* ``m::Int`` : number of adaptive update iterations :math:`m` that have been performed.
* ``mu::Float64`` : dual averaging parameter, defined as :math:`\mu = \log(10 \epsilon_0)`.
* ``nalpha::Integer`` : the total number :math:`n_\alpha` of leapfrog steps performed.
* ``nalpha::Int`` : the total number :math:`n_\alpha` of leapfrog steps performed.
* ``t0::Float64`` : dual averaging parameter, fixed at :math:`t_0 = 10`.
* ``target::Float64`` : target acceptance rate for the adaptive algorithm.

Expand Down
18 changes: 9 additions & 9 deletions src/Mamba.jl
Expand Up @@ -52,7 +52,7 @@ module Mamba
type ScalarLogical <: ScalarVariate
value::Float64
symbol::Symbol
nlink::Integer
nlink::Int
monitor::Vector{Int}
eval::Function
sources::Vector{Symbol}
Expand All @@ -62,7 +62,7 @@ module Mamba
type ArrayLogical{N} <: ArrayVariate{N}
value::Array{Float64,N}
symbol::Symbol
nlink::Integer
nlink::Int
monitor::Vector{Int}
eval::Function
sources::Vector{Symbol}
Expand All @@ -72,7 +72,7 @@ module Mamba
type ScalarStochastic <: ScalarVariate
value::Float64
symbol::Symbol
nlink::Integer
nlink::Int
monitor::Vector{Int}
eval::Function
sources::Vector{Symbol}
Expand All @@ -83,7 +83,7 @@ module Mamba
type ArrayStochastic{N} <: ArrayVariate{N}
value::Array{Float64,N}
symbol::Symbol
nlink::Integer
nlink::Int
monitor::Vector{Int}
eval::Function
sources::Vector{Symbol}
Expand Down Expand Up @@ -113,9 +113,9 @@ module Mamba
dependents::Vector{Symbol}
samplers::Vector{Sampler}
states::Vector{Vector{Float64}}
iter::Integer
burnin::Integer
chain::Integer
iter::Int
burnin::Int
chain::Int
hasinputs::Bool
hasinits::Bool
end
Expand All @@ -129,14 +129,14 @@ module Mamba
value::Array{Float64,3}
range::Range{Int}
names::Vector{String}
chains::Vector{Integer}
chains::Vector{Int}
end

immutable ModelChains <: AbstractChains
value::Array{Float64,3}
range::Range{Int}
names::Vector{String}
chains::Vector{Integer}
chains::Vector{Int}
model::Model
end

Expand Down
2 changes: 1 addition & 1 deletion src/model/core.jl
Expand Up @@ -13,7 +13,7 @@ function Model(; iter::Integer=0, burnin::Integer=0, chain::Integer=1,
chain, false, false)
g = graph(m)
V = vertices(g)
lookup = Dict{Symbol,Integer}()
lookup = Dict{Symbol,Int}()
for v in V
setindex!(lookup, v.index, v.key)
end
Expand Down
2 changes: 1 addition & 1 deletion src/model/graph.jl
Expand Up @@ -38,7 +38,7 @@ end

function graph(m::Model)
g = graph(KeyVertex{Symbol}[], Edge{KeyVertex{Symbol}}[])
lookup = Dict{Symbol,Integer}()
lookup = Dict{Symbol,Int}()
for key in keys(m, :all)
lookup[key] = length(lookup) + 1
add_vertex!(g, KeyVertex(lookup[key], key))
Expand Down
2 changes: 1 addition & 1 deletion src/model/simulation.jl
Expand Up @@ -137,7 +137,7 @@ function unlist(m::Model, monitoronly::Bool)
end

function unlist(m::Model, nkeys::Vector{Symbol}, transform::Bool=false)
N = Integer[m[key].nlink for key in nkeys]
N = Int[m[key].nlink for key in nkeys]
values = Array(Float64, sum(N))
i = 0
for k in 1:length(nkeys)
Expand Down
14 changes: 7 additions & 7 deletions src/output/chains.jl
Expand Up @@ -12,7 +12,7 @@ end

function Chains{T<:Real,U<:String,V<:Integer}(value::Array{T,3};
start::Integer=1, thin::Integer=1, names::Vector{U}=String[],
chains::Vector{V}=Integer[])
chains::Vector{V}=Int[])
n, p, m = size(value)

if length(names) == 0
Expand All @@ -22,27 +22,27 @@ function Chains{T<:Real,U<:String,V<:Integer}(value::Array{T,3};
end

if length(chains) == 0
chains = Integer[1:m;]
chains = Int[1:m;]
elseif length(chains) != m
error("size(value, 3) and chains dimensions must match")
end

v = convert(Array{Float64, 3}, value)
Chains(v, range(start, thin, n), String[names...], Integer[chains...])
Chains(v, range(start, thin, n), String[names...], Int[chains...])
end

function Chains{T<:Real,U<:String}(value::Matrix{T};
start::Integer=1, thin::Integer=1, names::Vector{U}=String[],
chains::Integer=1)
Chains(reshape(value, size(value, 1), size(value, 2), 1), start=start,
thin=thin, names=names, chains=Integer[chains])
thin=thin, names=names, chains=Int[chains])
end

function Chains{T<:Real}(value::Vector{T};
start::Integer=1, thin::Integer=1, names::String="Param1",
chains::Integer=1)
Chains(reshape(value, length(value), 1, 1), start=start, thin=thin,
names=String[names], chains=Integer[chains])
names=String[names], chains=Int[chains])
end


Expand Down Expand Up @@ -72,9 +72,9 @@ window2inds(c::AbstractChains, window) =
window2inds(c::AbstractChains, ::Colon) = window2inds(c, 1:size(c,1))
window2inds(c::AbstractChains, window::Range) = begin
range = @mapiters(window, c)
a = max(ceil(Integer, first(range)), 1)
a = max(ceil(Int, first(range)), 1)
b = step(window)
c = min(floor(Integer, last(range)), size(c.value,1))
c = min(floor(Int, last(range)), size(c.value,1))
a:b:c
end

Expand Down
4 changes: 2 additions & 2 deletions src/output/gewekediag.jl
Expand Up @@ -8,8 +8,8 @@ function gewekediag{T<:Real}(x::Vector{T}; first::Real=0.1, last::Real=0.5,
error("first and last sequences are overlapping")
end
n = length(x)
x1 = x[1:round(Integer, first * n)]
x2 = x[round(Integer, n - last * n + 1):n]
x1 = x[1:round(Int, first * n)]
x2 = x[round(Int, n - last * n + 1):n]
z = (mean(x1) - mean(x2)) /
sqrt(mcse(x1, etype; args...)^2 + mcse(x2, etype; args...)^2)
[round(z, 3), round(1.0 - erf(abs(z) / sqrt(2.0)), 4)]
Expand Down
4 changes: 2 additions & 2 deletions src/output/heideldiag.jl
@@ -1,8 +1,8 @@
function heideldiag{T<:Real}(x::Vector{T}; alpha::Real=0.05, eps::Real=0.1,
etype=:imse, start::Integer=1, args...)
n = length(x)
delta = trunc(Integer, 0.10 * n)
y = x[trunc(Integer, n / 2):end]
delta = trunc(Int, 0.10 * n)
y = x[trunc(Int, n / 2):end]
S0 = length(y) * mcse(y, etype; args...)^2
i, pvalue, converged, ybar = 1, 1.0, false, NaN
while i < n / 2
Expand Down
4 changes: 2 additions & 2 deletions src/output/plot.jl
Expand Up @@ -57,7 +57,7 @@ function densityplot(c::AbstractChains; legend::Bool=false,
end

function autocorplot(c::AbstractChains;
maxlag::Integer=round(Integer, 10*log10(length(c.range))),
maxlag::Integer=round(Int, 10*log10(length(c.range))),
legend::Bool=false, na...)
nrows, nvars, nchains = size(c.value)
plots = Array(Plot, nvars)
Expand Down Expand Up @@ -123,7 +123,7 @@ function draw(p::Array{Plot}; fmt::Symbol=:svg, filename::String="",

pp = nrow * ncol ## plots per page
ps = length(p) ## number of plots
np = ceil(Integer, ps / pp) ## number of pages
np = ceil(Int, ps / pp) ## number of pages

mat = Array(Context, pp)
for page in 1:np
Expand Down
2 changes: 1 addition & 1 deletion src/output/rafterydiag.jl
Expand Up @@ -3,7 +3,7 @@ function rafterydiag{T<:Real}(x::Vector{T}; q::Real=0.025, r::Real=0.005,
range::Range=1:length(x))
nx = length(x)
phi = sqrt(2.0) * erfinv(s)
nmin = ceil(Integer, q * (1.0 - q) * (phi / r)^2)
nmin = ceil(Int, q * (1.0 - q) * (phi / r)^2)
if nmin > nx
warn("At least $nmin samples are needed for specified q, r, and s")
kthin = burnin = total = NaN
Expand Down
2 changes: 1 addition & 1 deletion src/output/stats.jl
Expand Up @@ -53,7 +53,7 @@ end

function hpd{T<:Real}(x::Vector{T}; alpha::Real=0.05)
n = length(x)
m = max(1, ceil(Integer, alpha * n))
m = max(1, ceil(Int, alpha * n))

y = sort(x)
a = y[1:m]
Expand Down
10 changes: 5 additions & 5 deletions src/progress.jl
Expand Up @@ -11,15 +11,15 @@ end

type ChainProgress
frame::ChainProgressFrame
chain::Integer
iters::Integer
counter::Integer
runin::Integer
chain::Int
iters::Int
counter::Int
runin::Int
threshold::Float64
t0::Float64

function ChainProgress(frame::ChainProgressFrame, chain::Integer, iters::Integer)
new(frame, chain, iters, 0, max(1, min(10, round(Integer, 0.01 * iters))),
new(frame, chain, iters, 0, max(1, min(10, round(Int, 0.01 * iters))),
0.0, time())
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/samplers/amm.jl
Expand Up @@ -5,7 +5,7 @@
type AMMTune
adapt::Bool
beta::Real
m::Integer
m::Int
Mv::Vector{Float64}
Mvv::Matrix{Float64}
scale::Real
Expand Down
8 changes: 4 additions & 4 deletions src/samplers/amwg.jl
Expand Up @@ -4,9 +4,9 @@

type AMWGTune
adapt::Bool
accept::Vector{Integer}
batchsize::Integer
m::Integer
accept::Vector{Int}
batchsize::Int
m::Int
sigma::Vector{Float64}
target::Real
end
Expand All @@ -21,7 +21,7 @@ end
function AMWGVariate(x::Vector{Float64}, tune=nothing)
tune = AMWGTune(
false,
zeros(Integer, length(x)),
zeros(Int, length(x)),
50,
0,
Array(Float64, 0),
Expand Down
4 changes: 2 additions & 2 deletions src/samplers/nuts.jl
Expand Up @@ -10,9 +10,9 @@ type NUTSTune
gamma::Float64
Hbar::Float64
kappa::Float64
m::Integer
m::Int
mu::Float64
nalpha::Integer
nalpha::Int
t0::Float64
target::Float64
end
Expand Down

0 comments on commit 122db46

Please sign in to comment.