Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
femtocleaner[bot] committed Nov 6, 2017
1 parent 8d7883a commit fd4193e
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion examples/finite_dp_og_example.jl
Expand Up @@ -9,7 +9,7 @@ Filename: finite_dp_og.jl
Set up R, Q and beta, the three elements that define an instance of
the DiscreteDP object.
"""
type SimpleOG
mutable struct SimpleOG
#-Paramters-#
B::Int64
M::Int64
Expand Down
4 changes: 2 additions & 2 deletions other/ddpsolve.jl
@@ -1,5 +1,5 @@
# TODO: the stdlib function findmax(arr, dim) should do this now
function indvalmax{T}(a::Matrix{T}, dim::Integer=2)
function indvalmax(a::Matrix{T}, dim::Integer=2) where T
out_size = dim == 2 ? size(a, 1) : size(a, 2)
out_v = Array(T, out_size)
out_i = Array(Int64, out_size)
Expand Down Expand Up @@ -43,7 +43,7 @@ function expandg(g)
end


function diagmult{T <: Real}(a::Vector{T}, b::Matrix{T})
function diagmult(a::Vector{T}, b::Matrix{T}) where T <: Real
n = length(a)
return sparse(1:n, 1:n, a, n, n)*b
end
Expand Down
2 changes: 1 addition & 1 deletion other/quadrature.jl
@@ -1,4 +1,4 @@
function qnwbeta{T <: Real, S <: Real}(n::Int, a::T, b::S)
function qnwbeta(n::Int, a::T, b::S) where {T <: Real, S <: Real}
a -= 1
b -= 1

Expand Down
2 changes: 1 addition & 1 deletion src/QuantEcon.jl
Expand Up @@ -16,7 +16,7 @@ using Compat: view, @compat
end

# useful types
@compat ScalarOrArray{T} = Union{T,Array{T}}
ScalarOrArray{T} = Union{T,Array{T}}


export
Expand Down
2 changes: 1 addition & 1 deletion src/arma.jl
Expand Up @@ -65,7 +65,7 @@ require(joinpath(dirname(@__FILE__),"..", "examples", "arma_plots.jl"))
quad_plot(lp)
```
"""
type ARMA
mutable struct ARMA
phi::Vector # AR parameters phi_1, ..., phi_p
theta::Vector # MA parameters theta_1, ..., theta_q
p::Integer # Number of AR coefficients
Expand Down
12 changes: 6 additions & 6 deletions src/compute_fp.jl
Expand Up @@ -48,12 +48,12 @@ x_star = compute_fixed_point(x->T(x, 0.3), 0.4) # (4μ - 1)/(4μ)
```
"""
function compute_fixed_point{TV}(T::Function,
v::TV;
err_tol=1e-4,
max_iter=100,
verbose=2,
print_skip=10)
function compute_fixed_point(T::Function,
v::TV;
err_tol=1e-4,
max_iter=100,
verbose=2,
print_skip=10) where TV

if !(verbose in (0, 1, 2))
throw(ArgumentError("verbose should be 0, 1 or 2"))
Expand Down
8 changes: 4 additions & 4 deletions src/discrete_rv.jl
Expand Up @@ -28,16 +28,16 @@ vector of probabilities given by `q`.
- `q::AbstractVector`: A vector of non-negative probabilities that sum to 1
- `Q::AbstractVector`: The cumulative sum of `q`
"""
type DiscreteRV{TV1<:AbstractVector, TV2<:AbstractVector}
mutable struct DiscreteRV{TV1<:AbstractVector, TV2<:AbstractVector}
q::TV1
Q::TV2
function (::Type{DiscreteRV{TV1,TV2}}){TV1,TV2}(q, Q)
function DiscreteRV{TV1,TV2}(q, Q) where {TV1,TV2}
abs(Q[end] - 1) > 1e-10 && error("q should sum to 1")
new{TV1,TV2}(q, Q)
end
end

function DiscreteRV{TV<:AbstractVector}(q::TV)
function DiscreteRV(q::TV) where TV<:AbstractVector
Q = cumsum(q)
DiscreteRV{TV,typeof(Q)}(q, Q)
end
Expand Down Expand Up @@ -70,7 +70,7 @@ Make multiple draws from the discrete distribution represented by a
"""
Base.rand(d::DiscreteRV, k::Int) = Int[rand(d) for i=1:k]

function Base.rand!{T<:Integer}(out::AbstractArray{T}, d::DiscreteRV)
function Base.rand!(out::AbstractArray{T}, d::DiscreteRV) where T<:Integer
@inbounds for I in eachindex(out)
out[I] = rand(d)
end
Expand Down
2 changes: 1 addition & 1 deletion src/ecdf.jl
Expand Up @@ -17,7 +17,7 @@ observations.
- `observations::Vector`: The vector of observations
"""
type ECDF
mutable struct ECDF
observations::Vector
end

Expand Down
16 changes: 8 additions & 8 deletions src/interp.jl
Expand Up @@ -22,13 +22,13 @@ li.([0.1, 0.2, 0.3])
```
"""
immutable LinInterp{TV<:AbstractArray,TB<:AbstractVector}
struct LinInterp{TV<:AbstractArray,TB<:AbstractVector}
breaks::TB
vals::TV
_n::Int
_ncol::Int

function (::Type{LinInterp{TV,TB}}){TB,TV}(b::TB, v::TV)
function LinInterp{TV,TB}(b::TB, v::TV) where {TB,TV}
if size(b, 1) != size(v, 1)
m = "breaks and vals must have same number of elements"
throw(DimensionMismatch(m))
Expand All @@ -46,11 +46,11 @@ function Base.:(==)(li1::LinInterp, li2::LinInterp)
all(getfield(li1, f) == getfield(li2, f) for f in fieldnames(li1))
end

function LinInterp{TV<:AbstractArray,TB<:AbstractVector}(b::TB, v::TV)
function LinInterp(b::TB, v::TV) where {TV<:AbstractArray,TB<:AbstractVector}
LinInterp{TV,TB}(b, v)
end

@compat function (li::LinInterp{<:AbstractVector})(xp::Number)
function (li::LinInterp{<:AbstractVector})(xp::Number)
ix = searchsortedfirst(li.breaks, xp)

# handle corner cases
Expand All @@ -65,7 +65,7 @@ end
end
end

@compat function (li::LinInterp{<:AbstractMatrix})(xp::Number, col::Int)
function (li::LinInterp{<:AbstractMatrix})(xp::Number, col::Int)
ix = searchsortedfirst(li.breaks, xp)
@boundscheck begin
if col > li._ncol || col < 1
Expand All @@ -86,9 +86,9 @@ end
end
end

_out_eltype{TV,TB}(li::LinInterp{TV,TB}) = promote_type(eltype(TV), eltype(TB))
_out_eltype(li::LinInterp{TV,TB}) where {TV,TB} = promote_type(eltype(TV), eltype(TB))

@compat function (li::LinInterp{<:AbstractMatrix})(
function (li::LinInterp{<:AbstractMatrix})(
xp::Number, cols::AbstractVector{<:Integer}
)
ix = searchsortedfirst(li.breaks, xp)
Expand Down Expand Up @@ -130,7 +130,7 @@ _out_eltype{TV,TB}(li::LinInterp{TV,TB}) = promote_type(eltype(TV), eltype(TB))
end
end

@compat (li::LinInterp{<:AbstractMatrix})(xp::Number) = li(xp, 1:li._ncol)
(li::LinInterp{<:AbstractMatrix})(xp::Number) = li(xp, 1:li._ncol)

"""
interp(grid::AbstractVector, function_vals::AbstractVector)
Expand Down
2 changes: 1 addition & 1 deletion src/kalman.jl
Expand Up @@ -14,7 +14,7 @@ https://lectures.quantecon.org/jl/kalman.html
TODO: Do docstrings here after implementing LinerStateSpace
=#

type Kalman
mutable struct Kalman
A
G
Q
Expand Down
4 changes: 2 additions & 2 deletions src/lae.jl
Expand Up @@ -31,7 +31,7 @@ of observations `X`.
any kind of `AbstractArray` and will be coerced into an `n x 1` vector.
"""
type LAE
mutable struct LAE
p::Function
X::Matrix

Expand All @@ -55,7 +55,7 @@ values in the array `y`.
- `psi_vals::Vector`: Density at `(x, y)`
"""
function lae_est{T}(l::LAE, y::AbstractArray{T})
function lae_est(l::LAE, y::AbstractArray{T}) where T
k = length(y)
v = l.p(l.X, reshape(y, 1, k))
psi_vals = mean(v, 1)
Expand Down
6 changes: 3 additions & 3 deletions src/lqcontrol.jl
Expand Up @@ -72,7 +72,7 @@ case, ``V, P, d`` and ``F`` are all stationary.
- `F::ScalarOrArray` : Policy rule that specifies optimal control in each period
"""
type LQ
mutable struct LQ
Q::ScalarOrArray
R::ScalarOrArray
A::ScalarOrArray
Expand Down Expand Up @@ -236,7 +236,7 @@ end
"""
Private method implementing `compute_sequence` when state is a scalar
"""
function _compute_sequence{T}(lq::LQ, x0::T, policies)
function _compute_sequence(lq::LQ, x0::T, policies) where T
capT = length(policies)

x_path = Array{T}(capT+1)
Expand All @@ -259,7 +259,7 @@ end
"""
Private method implementing `compute_sequence` when state is a scalar
"""
function _compute_sequence{T}(lq::LQ, x0::Vector{T}, policies)
function _compute_sequence(lq::LQ, x0::Vector{T}, policies) where T
# Ensure correct dimensionality
n, j, k = size(lq.C, 1), size(lq.C, 2), size(lq.B, 2)
capT = length(policies)
Expand Down
4 changes: 2 additions & 2 deletions src/lss.jl
Expand Up @@ -50,7 +50,7 @@ where ``{w_t}`` and ``{v_t}`` are independent and standard normal with dimension
also should be positive definite and symmetric
"""
type LSS{TSampler<:MVNSampler}
mutable struct LSS{TSampler<:MVNSampler}
A::Matrix
C::Matrix
G::Matrix
Expand Down Expand Up @@ -139,7 +139,7 @@ end
replicate(lss::LSS; t::Integer=10, num_reps::Integer=100) =
replicate(lss, t, num_reps)

immutable LSSMoments
struct LSSMoments
lss::LSS
end

Expand Down

0 comments on commit fd4193e

Please sign in to comment.