codedthinking / Kezdi.jl

Julia package for data manipulation and analysis
https://codedthinking.github.io/Kezdi.jl/
Other
43 stars 2 forks source link

bug: replace `@if` does not work with user-defined function calls #185

Closed gergelyattilakiss closed 2 months ago

gergelyattilakiss commented 2 months ago
@replace id_type = 2 @if left(frame_id, 2) == "fc"

ERROR: ArgumentError: column name :left not found in the data frame
Stacktrace:
 [1] lookupname
   @ /srv/sandbox/kissg/.julia/packages/DataFrames/58MUJ/src/other/index.jl:413 [inlined]
 [2] getindex
   @ /srv/sandbox/kissg/.julia/packages/DataFrames/58MUJ/src/other/index.jl:422 [inlined]
 [3] getindex(df::DataFrame, ::typeof(!), col_ind::Symbol)
   @ DataFrames /srv/sandbox/kissg/.julia/packages/DataFrames/58MUJ/src/dataframe/dataframe.jl:557
 [4] getproperty(df::DataFrame, col_ind::Symbol)
   @ DataFrames /srv/sandbox/kissg/.julia/packages/DataFrames/58MUJ/src/abstractdataframe/abstractdataframe.jl:431
 [5] top-level scope
   @ /srv/sandbox/kissg/sandbox/Kezdi.jl/src/commands.jl:39

It seems to be looking for a column named left instead of the function call.

gergelyattilakiss commented 2 months ago

This is wierd bc it works with non-user generated functions.

@replace id_type = 3 @if ismissing(id_type) && originalid > 0

does work

gergelyattilakiss commented 2 months ago

Using Main.left()makes throws other error. it is about dimension mismatch.

@replace id_type = 2 @if Main.left(frame_id, 2) == "fc"

ERROR: DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 10071121 and 2
Stacktrace:
 [1] _bcs1
   @ ./broadcast.jl:555 [inlined]
 [2] _bcs
   @ ./broadcast.jl:549 [inlined]
 [3] broadcast_shape
   @ ./broadcast.jl:543 [inlined]
 [4] combine_axes
   @ ./broadcast.jl:524 [inlined]
 [5] instantiate
   @ ./broadcast.jl:306 [inlined]
 [6] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{…}, Nothing, typeof(==), Tuple{…}})
   @ Base.Broadcast ./broadcast.jl:903
 [7] top-level scope
   @ /srv/sandbox/kissg/sandbox/Kezdi.jl/src/commands.jl:39
Some type information was truncated. Use `show(err)` to see complete types.
gergelyattilakiss commented 2 months ago

Since this is not an issue with @generate I will look up and check how it works there and will try a solution that mimics it.

korenmiklos commented 2 months ago

This is fixed in #182