JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
436 stars 88 forks source link

The broadcast pipe operator doesn't get recognized by the @df macro #540

Open bertulli opened 1 year ago

bertulli commented 1 year ago

Hi all!

I found this error:

    @df df_pair_temp zip(cols(instruction_pair_first_sym), cols(:first_encoding)) |>
    collect .|>
    x -> x

raises

julia> @df df_pair_temp zip(cols(instruction_pair_first_sym), cols(:first_encoding)) |>
           collect .|>
           x -> x
ERROR: UndefVarError: `.|>` not defined
Stacktrace:
 [1] (::var"#57#59")(390::DataFrame)
   @ Main ./none:0
 [2] top-level scope
   @ REPL[41]:1

I thought maybe the @df macro is disturbing something, as I get:

julia> @macroexpand @df df_pair_temp zip(cols(instruction_pair_first_sym), cols(:first_encoding)) |>
           collect .|>
           x -> x
:(((var"##394"->begin
          ((var"##range#395", var"##range#396"), var"##397") = (StatsPlots).extract_columns_and_names(var"##394", instruction_pair_first_sym, :first_encoding)
          (StatsPlots).add_label(["zip(cols(instruction_pair_first_sym), cols(first_encoding)) |> collect", "x->begin\n        #= REPL[42]3 =#\n        x\n    end"], .|>, zip(var"##range#395", var"##range#396") |> collect, (x->begin
                      #= REPL[42]:3 =#
                      x
                  end))
      end))(df_pair_temp))

Notice the .|> interpreted as a variable (if I understood it correctly).

Thanks!