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

Commit 77c2592

Browse files
LouisMagarshackandreasnoack
authored andcommitted
Fix MethodError when calling groupby, unstack, etc (#274)
* Fix MethodError when calling groupby, unstack, etc * Fix PooledDataArray for types such that convert(typeof(d), unique(d)) does not exist. Add 2 unit tests for issue #273 * More concise notation for the convert in PDAs
1 parent 5eb6b7d commit 77c2592

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/pooleddataarray.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ end
137137
function PooledDataArray{T,R<:Integer,N}(d::AbstractArray{T, N},
138138
m::AbstractArray{Bool, N},
139139
r::Type{R} = DEFAULT_POOLED_REF_TYPE)
140-
pool = convert(Array, unique(d[.!m]))
140+
pool = convert(Vector{T}, unique(d[.!m]))
141141
if method_exists(isless, (T, T))
142142
sort!(pool)
143143
end

test/pooleddataarray.jl

+11
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,15 @@
140140
end
141141
z = PooledDataArray([1, 2], [1, 2, 3])
142142
@test sort(unique(z)) == DataArray([1, 2])
143+
144+
145+
# Issue #273
146+
# Ensure that PooledDataArray works for arrays with non leaf type elements.
147+
# Those two examples used to throw exceptions.
148+
x = AbstractString["a"]
149+
m = Bool[false]
150+
r = UInt32
151+
@test isa(PooledDataArray(x, m, r), DataArrays.PooledDataArray{AbstractString, UInt32, 1})
152+
x = Integer[1]
153+
@test isa(PooledDataArray(x, m, r), DataArrays.PooledDataArray{Integer, UInt32, 1})
143154
end

0 commit comments

Comments
 (0)