Skip to content

Commit

Permalink
exported HOFs all do thunk
Browse files Browse the repository at this point in the history
Some functions have a method whose final arg is a function.
The do block idiom doesn't work for those methods, so alternate methods
were added (exported functions with a single function arg only).
  • Loading branch information
garborg committed Jul 7, 2014
1 parent 1946ebe commit 7f8afda
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dataframe/reshape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
# `mean` is the default aggregation function:
pivottable(df::AbstractDataFrame, rows, cols, value) = pivottable(df, rows, cols, value, mean)
pivottable(df::AbstractDataFrame, rows, cols, value, fun) = pivottable(df, [index(df)[rows]], [index(df)[cols]], index(df)[value], fun)

pivottable(fun::Function, df::AbstractDataFrame, rows, cols, value) = pivottable(df, rows, cols, value, fun)

##############################################################################
##
Expand Down
1 change: 1 addition & 0 deletions src/groupeddataframe/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@ Base.names(d::GroupedDataFrame) = names(d.parent)

# by() convenience function
by(d::AbstractDataFrame, cols, f::Function) = based_on(groupby(d, cols), f)
by(f::Function, d::AbstractDataFrame, cols) = by(d, cols, f)
by(d::AbstractDataFrame, cols, s::Vector{Symbol}) = colwise(groupby(d, cols), s)
by(d::AbstractDataFrame, cols, s::Symbol) = colwise(groupby(d, cols), s)
2 changes: 2 additions & 0 deletions src/other/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ end
rename!(x::Index, from, to) = rename!(x, zip(from, to))
rename!(x::Index, from::Symbol, to::Symbol) = rename!(x, ((from, to),))
rename!(x::Index, f::Function) = rename!(x, [(x,f(x)) for x in x.names])
rename!(f::Function, x::Index) = rename!(x, f)

rename(x::Index, args...) = rename!(copy(x), args...)
rename(f::Function, x::Index) = rename(x, f)

Base.haskey(x::Index, key::Symbol) = haskey(x.lookup, key)
Base.haskey(x::Index, key::Real) = 1 <= key <= length(x.names)
Expand Down

0 comments on commit 7f8afda

Please sign in to comment.