codedthinking / Kezdi.jl

An umbrella of Julia packages for data analysis, in loving memory of Gábor Kézdi
Other
9 stars 0 forks source link

bug: `in` does not work neither in assignment nor in if #65

Closed korenmiklos closed 4 days ago

korenmiklos commented 1 week ago
@keep df @if canonical_form in ["summarize", "generate"]

DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 799670 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{1}, Nothing, typeof(in), Tuple{Vector{String}, Vector{String}}})
   @ Base.Broadcast ./broadcast.jl:903
 [7] top-level scope
   @ [~/.julia/packages/Kezdi/aWW9R/src/codegen.jl:108](http://localhost:8888/lab/workspaces/auto-a/tree/~/.julia/packages/Kezdi/aWW9R/src/codegen.jl#line=107)

@generate df y = (canonical_form in ["summarize", "generate"])

DimensionMismatch: array could not be broadcast to match destination

Stacktrace:
 [1] check_broadcast_shape
   @ ./broadcast.jl:579 [inlined]
 [2] check_broadcast_axes
   @ ./broadcast.jl:582 [inlined]
 [3] check_broadcast_axes
   @ ./broadcast.jl:586 [inlined]
 [4] instantiate
   @ ./broadcast.jl:309 [inlined]
 [5] materialize!
   @ ./broadcast.jl:914 [inlined]
 [6] materialize!(dest::DataFrames.LazyNewColDataFrame{Symbol, SubDataFrame{DataFrame, DataFrames.Index, UnitRange{Int64}}}, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(in), Tuple{SubArray{String, 1, Vector{String}, Tuple{UnitRange{Int64}}, true}, Vector{String}}})
   @ Base.Broadcast ./broadcast.jl:911
 [7] top-level scope
   @ [~/.julia/packages/Kezdi/aWW9R/src/codegen.jl:39](http://localhost:8888/lab/workspaces/auto-a/tree/~/.julia/packages/Kezdi/aWW9R/src/codegen.jl#line=38)
gergelyattilakiss commented 6 days ago

This seems to be working now, passing my tests.

korenmiklos commented 5 days ago

For me they're still not working.

True: Error During Test at /Users/koren/Tresorit/Mac/code/julia/Kezdi.jl/test/commands.jl:284
  Got exception outside of a @test
  DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 4 and 2
gergelyattilakiss commented 5 days ago

It was before I corrected the tests and parsing.

korenmiklos commented 5 days ago

Maybe I messed up the merge. Can you check why these two tests are failing?

gergelyattilakiss commented 5 days ago

It was failing last night too when I finished, so it was definitely not the refactor.

korenmiklos commented 5 days ago

The issue is the list. When the RHS is a list, the code will get confused. Try doing with with saving the list in a function, like

flist() = ["a", "b", "c"]
@generate df y = x in flist()

This should work.

Btw, this is also a way of bringing in locals w/o getting replaced by symbol.

gergelyattilakiss commented 5 days ago

Then definitely this should be the way.

gergelyattilakiss commented 5 days ago

Implementing it on main

korenmiklos commented 5 days ago

Related to #71

korenmiklos commented 4 days ago

Will be solved in #71