Skip to content

Commit

Permalink
Fix typo in gridmake and add method for a tuple of ints (QuantEcon#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
sglyon authored Nov 7, 2016
1 parent 3aeaf09 commit 390b6f9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ end
function gridmake(arrays::AbstractVector...)
l = prod([length(a) for a in arrays])
T = reduce(promote_type, [eltype(a) for a in arrays])
gridmake!(Array(T, l, length(arrays)), arrays...)
out = Array(T, l, length(arrays))
gridmake!(out, arrays...)
out
end

Expand All @@ -80,6 +81,12 @@ function gridmake{T}(arrays::AbstractVector{T}...)
gridmake!(out, arrays...)
end

function gridmake(t::Tuple)
all(map(x -> isa(x, Integer), t)) ||
error("gridmake(::Tuple) only valid when all elements are integers")
gridmake(map(x->1:x, t)...)::Matrix{Int}
end

"""
`gridmake(arrays::AbstractVector...)`
Expand Down

0 comments on commit 390b6f9

Please sign in to comment.