Skip to content
This repository was archived by the owner on May 5, 2019. It is now read-only.

Commit c4e218e

Browse files
committed
DataFrames doensn't reshape 2d Arrays -> Vectors so don't do it here
1 parent 06dc914 commit c4e218e

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/datatable/datatable.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ type DataTable <: AbstractDataTable
7979
elseif length(columns) != length(colindex)
8080
throw(DimensionMismatch("Number of columns ($(length(columns))) and column names ($(length(colindex))) are not equal"))
8181
end
82-
# do we allow people assigning arrays to columns now?
83-
# make sure that doesn't work
84-
# can use !get(size(c, 2), 0)
8582
lengths = length.(columns)
8683
minlen, maxlen = extrema(lengths)
8784
if minlen == 0 && maxlen == 0
@@ -91,7 +88,7 @@ type DataTable <: AbstractDataTable
9188
if minlen == 1 && maxlen > 1
9289
indices = find(lengths .== minlen)
9390
for i in indices
94-
if !(typeof(columns[i]) <: AbstractArray)
91+
if !(typeof(columns[i]) <: AbstractVector)
9592
columns[i] = fill(columns[i], maxlen)
9693
lengths[i] = maxlen
9794
end
@@ -112,7 +109,7 @@ type DataTable <: AbstractDataTable
112109
if isa(c, Range)
113110
columns[i] = collect(c)
114111
elseif !isa(c, AbstractVector)
115-
columns[i] = size(c, 2) > 1 ? reshape(c, length(c)) : [c]
112+
columns[i] = size(c, 2) > 1 ? throw(DimensionMismatch("columns must be 1-dimensional")) : [c]
116113
end
117114
end
118115
return new(columns, colindex)

test/constructors.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module TestConstructors
6464
@testset "constructor errors" begin
6565
@test_throws DimensionMismatch DataTable(a=1, b=[])
6666
@test_throws DimensionMismatch DataTable(Any[collect(1:10)], DataTables.Index([:A, :B]))
67+
@test_throws DimensionMismatch DataTable(A = rand(2,2))
6768
end
6869

6970
@testset "column types" begin

0 commit comments

Comments
 (0)