From 77eaef75bfe5bde7b62e8d93834617db1d7a6b66 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Date: Thu, 3 Aug 2023 22:31:31 -0400 Subject: [PATCH] Create global variable for not_vectorized vector so other packages can modify it. --- src/TidierData.jl | 3 +++ src/parsing.jl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TidierData.jl b/src/TidierData.jl index 154ed22d..ce5af439 100644 --- a/src/TidierData.jl +++ b/src/TidierData.jl @@ -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") diff --git a/src/parsing.jl b/src/parsing.jl index 3fc2c809..67861b5d 100644 --- a/src/parsing.jl +++ b/src/parsing.jl @@ -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...)))