Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create global variable for not_vectorized vector so other packages can modify it. #20

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/TidierData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export TidierData_set, across, desc, n, row_number, starts_with, ends_with, matc
const code = Ref{Bool}(false) # output DataFrames.jl code?
const log = Ref{Bool}(false) # output tidylog output? (not yet implemented)

# Expose the global do-not-vectorize "list"
const not_vectorized = Ref{Vector{Symbol}}([:Ref, :Set, :Cols, :(:), :∘, :lag, :lead, :ntile, :repeat, :across, :desc, :mean, :std, :var, :median, :first, :last, :minimum, :maximum, :sum, :length, :skipmissing, :quantile, :passmissing, :cumsum, :cumprod, :accumulate])

# Includes
include("docstrings.jl")
include("parsing.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function parse_autovec(tidy_expr::Union{Expr,Symbol})
elseif @capture(x, fn_(args__))
# This is the do-not-vectorize "list"
# `in` should be vectorized so do not add to this exclusion list
if fn in [:Ref :Set :Cols :(:) :∘ :lag :lead :ntile :repeat :across :desc :mean :std :var :median :first :last :minimum :maximum :sum :length :skipmissing :quantile :passmissing :cumsum :cumprod :accumulate]
if fn in not_vectorized[]
return x
elseif contains(string(fn), r"[^\W0-9]\w*$") # valid variable name
return :($fn.($(args...)))
Expand Down