-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] work towards updating to DataFrames v0.11+ framework #1088
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const NumericalOrCategoricalAesthetic = | ||
Union{(Void), Vector, DataArray, PooledDataArray} | ||
Union{(Void), Vector, DataArray, CategoricalArray} | ||
|
||
const CategoricalAesthetic = | ||
Union{(Void), PooledDataArray} | ||
Union{(Void), CategoricalArray} | ||
|
||
const NumericalAesthetic = | ||
Union{(Void), Matrix, Vector, DataArray} | ||
|
@@ -287,18 +287,8 @@ function cat_aes_var!{T, U}(a::AbstractArray{T}, b::AbstractArray{U}) | |
return ab | ||
end | ||
|
||
function cat_aes_var!{T}(xs::PooledDataVector{T}, ys::PooledDataVector{T}) | ||
newpool = T[x for x in union(Set(xs.pool), Set(ys.pool))] | ||
newdata = vcat(T[x for x in xs], T[y for y in ys]) | ||
PooledDataArray(newdata, newpool, [false for _ in newdata]) | ||
end | ||
|
||
function cat_aes_var!{T, U}(xs::PooledDataVector{T}, ys::PooledDataVector{U}) | ||
V = promote_type(T, U) | ||
newpool = V[x for x in union(Set(xs.pool), Set(ys.pool))] | ||
newdata = vcat(V[x for x in xs], V[y for y in ys]) | ||
PooledDataArray(newdata, newpool, [false for _ in newdata]) | ||
end | ||
cat_aes_var!{T}(xs::CategoricalArray{T}, ys::CategoricalArray{T}) = vcat(xs, ys) | ||
cat_aes_var!{T, U}(xs::CategoricalArray{T}, ys::CategoricalArray{U}) = vcat(xs, ys) | ||
|
||
|
||
# Summarizing aesthetics | ||
|
@@ -333,11 +323,6 @@ function by_xy_group{T <: Union{Data, Aesthetics}}(aes::T, xgroup, ygroup, | |
|
||
xgroup === nothing && ygroup === nothing && return aes_grid | ||
|
||
make_pooled_data_array{T,U,V}(::Type{PooledDataArray{T,U,V}}, arr::AbstractArray) = | ||
PooledDataArray(convert(Array{T}, arr)) | ||
make_pooled_data_array{T,U,V}(::Type{PooledDataArray{T,U,V}}, | ||
arr::PooledDataArray{T,U,V}) = arr | ||
|
||
for var in fieldnames(T) | ||
# Skipped aesthetics. Don't try to partition aesthetics for which it | ||
# makes no sense to pass on to subplots. | ||
|
@@ -366,9 +351,8 @@ function by_xy_group{T <: Union{Data, Aesthetics}}(aes::T, xgroup, ygroup, | |
end | ||
|
||
for i in 1:n, j in 1:m | ||
if typeof(vals) <: PooledDataArray | ||
setfield!(aes_grid[i, j], var, | ||
make_pooled_data_array(typeof(vals), staging[i, j])) | ||
if typeof(vals) <: CategoricalArray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
setfield!(aes_grid[i, j], var, CategoricalArray(staging[i, j])) | ||
else | ||
if !applicable(convert, typeof(vals), staging[i, j]) | ||
T2 = eltype(vals) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#Is this usable data? | ||
isconcrete{T<:Number}(x::T) = !isna(x) && isfinite(x) | ||
isconcrete{T<:Number}(x::T) = !ismissing(x) && isfinite(x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it should be something like: isconcrete(::Missing) = false
isconcrete(x::Number) = isfinite(x) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. This should fix #1083 too, I think |
||
isconcrete(x::(Irrational)) = true | ||
isconcrete(x) = !isna(x) | ||
isconcrete(x) = !ismissing(x) | ||
|
||
hasna(xs) = false | ||
|
||
function hasna(xs::AbstractDataArray) | ||
for x in xs | ||
if isna(x) | ||
if ismissing(x) | ||
return true | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW,
cat_aes_var{T}(...)
is pre-0.6 syntax. Since DataFrames 0.11 requires 0.6, it's better write it ascat_aes_var(...) where {T}
, although in this particular case it could be as simple as (replaces both definitions)