working on groups and iris notebook

This commit is contained in:
Thomas Breloff 2015-09-23 23:34:54 -04:00
parent 431d60a58a
commit dbc90c9417
3 changed files with 1619 additions and 51 deletions

File diff suppressed because one or more lines are too long

View File

@ -261,7 +261,7 @@ end
# this is when given a vector-type of values to group by
function extractGroupArgs(v::AVec, d::Dict)
function extractGroupArgs(v::AVec, args...)
groupLabels = sort(collect(unique(v)))
n = length(groupLabels)
if n > 20
@ -273,23 +273,13 @@ end
# expecting a mapping of "group label" to "group indices"
function extractGroupArgs{T, V<:AVec{Int}}(idxmap::Dict{T,V}, d::Dict)
function extractGroupArgs{T, V<:AVec{Int}}(idxmap::Dict{T,V}, args...)
groupLabels = sortedkeys(idxmap)
groupIds = VecI[collect(idxmap[k]) for k in groupLabels]
GroupBy(groupLabels, groupIds)
end
# expecting the column name of a dataframe that was passed in... anything else should error
function extractGroupArgs(s::Symbol, d::Dict)
if haskey(d, :dataframe) && haskey(d[:dataframe], s)
return extractGroupArgs(d[:dataframe][s])
else
error("Got a symbol, and expected that to be a key in d[:dataframe]. s=$s d=$d")
end
end
# -----------------------------------------------------------------------------
function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)

View File

@ -88,7 +88,7 @@ function plot!(plt::Plot, args...; kw...)
# index partitions/filters to be passed through to the next step.
# Ideally we don't change the insides ot createKWargsList too much to
# save from code repetition. We could consider adding a throw
groupargs = haskey(d, :group) ? [extractGroupArgs(d[:group], d)] : []
groupargs = haskey(d, :group) ? [extractGroupArgs(d[:group], args...)] : []
# @show groupargs
# just in case the backend needs to set up the plot (make it current or something)
@ -303,6 +303,15 @@ function dataframes!()
createKWargsList(plt, args...; kw..., dataframe = df)
end
# expecting the column name of a dataframe that was passed in... anything else should error
@eval function extractGroupArgs(s::Symbol, df::DataFrames.DataFrame, args...)
if haskey(df, s)
return extractGroupArgs(df[s])
else
error("Got a symbol, and expected that to be a key in d[:dataframe]. s=$s d=$d")
end
end
@eval function getDataFrameFromKW(; kw...)
for (k,v) in kw
if k == :dataframe