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

Strange interaction between DataArrays.jl and Gadfly.jl #232

Closed
joshbode opened this issue Jan 13, 2017 · 3 comments
Closed

Strange interaction between DataArrays.jl and Gadfly.jl #232

joshbode opened this issue Jan 13, 2017 · 3 comments

Comments

@joshbode
Copy link
Contributor

joshbode commented Jan 13, 2017

I'm getting a strange error which appears to be an interaction between Gadfly and DataArrays.
Specifically, map! is failing in certain cases, but only when Gadfly is imported.

Here is a simple example (verified using Julia 0.5 on OS X and Linux):

using DataArrays
using Gadfly

function foo{S <: Real, T <: Real}(x::AbstractArray{S}, y::AbstractArray{T})
    result = DataArray(Float64, length(x))
    map!((a, b) -> (isna(a) || isna(b)) ? NA : a + b, result, x, y)
end

function bar{S <: Real, T <: Real}(x::AbstractArray{S}, y::AbstractArray{T})
    result = DataArray(Float64, length(x))
    map!((a, b) -> a + b, result, x, y)
end

I get the following error:

julia> x = DataArray(1:10)
julia> y = DataArray(fill(1.0, 10))
julia> foo(x, y)
ERROR: TypeError: non-boolean (Bool) used in boolean context
 in (::##1#2)(::Int64, ::Float64) at ./REPL[3]:3
 in macro expansion at /Users/josh/.julia/v0.5/DataArrays/src/broadcast.jl:59 [inlined]
 in macro expansion at ./cartesian.jl:64 [inlined]
 in (::DataArrays.#_F_#203)(::DataArrays.DataArray{Float64,1}, ::DataArrays.DataArray{Int64,1}, ::DataArrays.DataArray{Float64,1}) at /Users/josh/.julia/v0.5/DataArrays/src/broadcast.jl:130
 in map!(::Function, ::DataArrays.DataArray{Float64,1}, ::DataArrays.DataArray{Int64,1}, ::DataArrays.DataArray{Float64,1}) at /Users/josh/.julia/v0.5/DataArrays/src/broadcast.jl:214
 in foo(::DataArrays.DataArray{Int64,1}, ::DataArrays.DataArray{Float64,1}) at ./REPL[3]:3

Note: if Gadfly is not loaded, then the call to foo works as expected with out error (I did say the issue was strange!). The error is also present if Gadfly is imported before DataArrays.

Also, the following calls do work, regardless of whether Gadfly is imported:

foo(x, x)
foo(y, y)
foo(y, x)  # ???!!!
bar(x, y)
bar(y, x)
bar(y, y)

So, it may have something to do with type conversion/promotion (or return type inference?), but as for why/how it involves Gadfly, I have no idea!

@joshbode
Copy link
Contributor Author

If the additional precompilation in Gadfly (see precompile.jl) is disabled, then the error goes away.

@nalimilan
Copy link
Member

Isn't that only on Julia 0.6? I think we've seen similar errors related to broadcast in DataArrays tests.

@joshbode
Copy link
Contributor Author

joshbode commented Feb 1, 2017

Closing - this appears to have been addressed in the release-0.5 branch, probably via JuliaLang/julia/pull/18869

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

2 participants