Skip to content

Commit

Permalink
Fix _fnames() with Julia 0.5
Browse files Browse the repository at this point in the history
Anonymous functions have their own names now.
  • Loading branch information
nalimilan committed Feb 11, 2016
1 parent ae2c1b1 commit 92332ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/other/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ end
function _fnames{T<:Function}(fs::Vector{T})
λcounter = 0
names = map(fs) do f
if isempty(f.env) # Anonymous function
name = string(f)
if name == "(anonymous function)" # Anonymous functions with Julia < 0.5
λcounter += 1
name = "λ$(λcounter)"
else
name = string(f.env.name)
end
name
end
Expand Down
6 changes: 5 additions & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ module TestUtils
@test DataFrames.countna(pdata) == 20

funs = [mean, sum, var, x -> sum(x)]
@test DataFrames._fnames(funs) == ["mean", "sum", "var", "λ1"]
if string(funs[end]) == "(anonymous function)" # Julia < 0.5
@test map(string, funs) == ["mean", "sum", "var", "λ1"]
else
@test map(string, funs) == ["mean", "sum", "var", string(funs[end])]
end
end

0 comments on commit 92332ff

Please sign in to comment.