codedthinking / Kezdi.jl

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

bug: elementwise && #135

Closed korenmiklos closed 2 days ago

korenmiklos commented 3 days ago
julia> @generate in1990 = (Main.get_year(founding_date) <= 1990) && ((STATUS == "ACTIVE") || (Main.get_year(death_date) >= 1991))
ERROR: TypeError: non-boolean (BitVector) used in boolean context
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/Kezdi/E9Dg4/src/commands.jl:28

julia> @generate in1990 = (Main.get_year(founding_date) <= 1990) .&& ((STATUS == "ACTIVE") .|| (Main.get_year(death_date) >= 1991))
2005350×8 DataFrame
gergelyattilakiss commented 3 days ago

Here I think the solution should be the same as for @if which luccily is already implemented.

korenmiklos commented 3 days ago

No, in both cases, autovectorization should take care of this. The question is why these operators are not autovectorized.

korenmiklos commented 3 days ago

This looks relevant:

julia> dump(:(a & b))
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol &
    2: Symbol a
    3: Symbol b

julia> dump(:(a && b))
Expr
  head: Symbol &&
  args: Array{Any}((2,))
    1: Symbol a
    2: Symbol b
korenmiklos commented 3 days ago

Indeed: https://docs.julialang.org/en/v1/devdocs/ast/#Operators