Skip to content

Commit

Permalink
Merge pull request JuliaPlots#135 from piever/fix
Browse files Browse the repository at this point in the history
Fix JuliaPlots#134 : typo on df blocks
  • Loading branch information
Pietro Vertechi authored Mar 16, 2018
2 parents 2aa99e0 + ab58a29 commit a05f771
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

## 0.7 current version

### 0.7.2

- fix stack overflow with `@df` and `begin ... end` blocks
- avoid recomputing data unnecessarily in `@df`

### 0.7.1

- remove Loess dependency
Expand Down
12 changes: 8 additions & 4 deletions src/df.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for strings and symbols respectively.
`x` can be either a plot command or a block of plot commands.
"""
macro df(d, x)
esc(df_helper(d, x))
esc(Expr(:call, df_helper(x), d))
end

"""
Expand All @@ -20,13 +20,17 @@ end
Curried version of `@df d x`. Outputs an anonymous function `d -> @df d x`.
"""
macro df(x)
esc(df_helper(x))
end

function df_helper(x)
i = gensym()
esc(Expr(:(->), i, df_helper(i, x)))
Expr(:(->), i, df_helper(i, x))
end

function df_helper(d, x)
if isa(x, Expr) && x.head == :block
commands = [:(@df($d, $x)) for xx in x.args if !(isa(xx, Expr) && xx.head == :line)]
commands = [df_helper(d, xx) for xx in x.args if !(isa(xx, Expr) && xx.head == :line)]
return Expr(:block, commands...)
elseif isa(x, Expr) && x.head == :call
syms = Any[]
Expand Down Expand Up @@ -61,7 +65,7 @@ function parse_iterabletable_call!(d, x::Expr, syms, vars)
x.args[1] == :^ && length(x.args) == 2 && return x.args[2]
if x.args[1] == :cols
if length(x.args) == 1
push!(x.args, :(StatPlots.column_names(StatPlots.getiterator(df))))
push!(x.args, :(StatPlots.column_names(StatPlots.getiterator($d))))
return parse_iterabletable_call!(d, x, syms, vars)
end
range = x.args[2]
Expand Down

0 comments on commit a05f771

Please sign in to comment.