Skip to content

protect is not respected in some cases #290

@kleinschmidt

Description

@kleinschmidt
julia> d = (; a=rand(10), b=rand(10));

julia> f = @formula(0 ~ protect(unprotect(a + b + protect(a * b))))
FormulaTerm
Response:
  0
Predictors:
  (a,b)->protect(unprotect(a + b + protect(a * b)))

julia> apply_schema(f, schema(f, d))
FormulaTerm
Response:
  0
Predictors:
  a(continuous)
  b(continuous)
  a(continuous) & b(continuous)

vs.

julia> f = @formula(0 ~ a + b + protect(a * b))
FormulaTerm
Response:
  0
Predictors:
  a(unknown)
  b(unknown)
  (a,b)->protect(a * b)

julia> apply_schema(f, schema(f, d))
FormulaTerm
Response:
  0
Predictors:
  a(continuous)
  b(continuous)
  (a,b)->a * b

The real place this comes up in practice is when trying to add special syntax like in kleinschmidt/RegressionFormulae.jl#13 that correctly respects protect inside it. The protect(unprotect(... dance is mimicking how apply_schema gets triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions