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

What should be the output of logical operators for PooledDataArray objects? #151

Open
heliosdrm opened this issue May 21, 2015 · 2 comments

Comments

@heliosdrm
Copy link

Now it is another PooledDataArray of Bool elements (possible levels: true or false).

I wonder if that really makes sense, or it should be just a DataArray of Bool. There are some operations, like element-wise logical operators, that do not work with PooledDataArray, so the current behaviour is problematic. A short example below (Julia 0.3.4 for Windows 64-bit, DataArrays 0.2.14).

julia> x = @pdata(["A","A","B","B"])
4-element PooledDataArray{ASCIIString,Uint32,1}:
 "A"
 "A"
 "B"
 "B"

julia> y = @data([1,2,1,3])
4-element DataArray{Int64,1}:
 1
 2
 1
 3

julia> x .== "A"
4-element PooledDataArray{Bool,Uint32,1}:
  true
  true
 false
 false

julia> y .< 2
4-element DataArray{Bool,1}:
  true
 false
  true
 false

julia> (x .== "A") & (y .< 2)
ERROR: `&` has no method matching &(::Array{Bool,1}, ::PooledDataArray{Bool,Uint32,1})
 in & at D:\.julia\v0.3\DataArrays\src\operators.jl:543
@johnmyleswhite
Copy link
Member

I would say we should just special-case ban PooledDataArray{Bool}. If you wanted to use it as factor, it already defines its own dummy representation. And it wastes storage since a bool costs less than any index into a pool of 2 values would.

@nalimilan
Copy link
Member

Actually, the error here is rather that logical operators shouldn't return a PDA, but a standard Array{Bool} or a BitArray. We could ban PooledDataArray{Bool}, but that's a different issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants