Skip to content

Commit

Permalink
Rename vardim to dims
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Feb 9, 2019
1 parent 545778b commit 769487c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ Tables.matrix(table; vardim::Int=2)
Materialize any table source input as a `Matrix`. If the table column types are not homogenous,
they will be promoted to a common type in the materialized `Matrix`. Note that column names are
ignored in the conversion.
ignored in the conversion. By default, input table columns will be materialized as corresponding
matrix columns; passing `dims=1` will transpose the input with input columns as matrix rows.
"""
function matrix(table; vardim::Int=2)
vardim == 1 || vardim == 2 || throw(ArgumentError("`vardim` keyword argument must be 1 or 2"))
function matrix(table; dims::Int=2)
dims == 1 || dims == 2 || throw(ArgumentError("`dims` keyword argument must be 1 or 2"))
cols = Tables.columns(table)
types = schema(cols).types
T = reduce(promote_type, types)
n, p = rowcount(cols), length(types)
if vardim == 2
if dims == 2
mat = Matrix{T}(undef, n, p)
for (i, col) in enumerate(Tables.eachcolumn(cols))
mat[:, i] = col
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ end
@test eltype(mat2) == Float64
@test mat2[:, 1] == nt.a
@test !Tables.istable(mat2)
mat3 = Tables.matrix(nt; vardim=1)
mat3 = Tables.matrix(nt; dims=1)
@test size(mat3) == (2, 3)
@test mat3[1, :] == nt.a
@test mat3[2, :] == nt.b
Expand Down

0 comments on commit 769487c

Please sign in to comment.