-
FunctionTerm
rework (#183)-
FunctionTerm{F,Args}
now stores the called function, the original expression, and the arguments (wrapped inTerm
/ConstantTerm
s). Package maintainers that rely onFunctionTerm
representations to implement special syntax will need to substantially update that existing code. This may be as simple as defining a run-time method formy_fun
that takes inAbstractTerm
s and returnsMyTermType
with an accompanying method forapply_schema(::FunctionTerm{typeof(my_fun)}, ...
that recursively applies the schema to the captured arguments and calls the run-time method:my_fun(args::AbstractTerm...) = MyTermType(args...) function apply_schema(t::FunctionTerm{typeof(my_fun)}, schema, Ctx) args = apply_schema.(t.args, Ref(schema), Ref(Ctx)) return t.f(args...) end
However, if the
@formula
syntax (i.e.,&
for interaction,+
for union, etc.) should apply within the call tomy_fun
, then care needs to be taken to un-protect any nested calls as necessary (although this is only likely to be a concern if the special syntax occurs as a child of another, non-special call). The above recommendation may still Just Work™ but some thorough testing is recommended. -
It is now possible (although not exactly convenient) to construct
FunctionTerm
s at run-time (i.e., outside of a@formula
macro). See the tests for an example of how this might be accomplished in practice. -
Special syntax is introduced to
protect
function calls from the usual@formula
interpretation (i.e., to treat+
as addition, useprotect(a + b)
) andunprotect
calls, switching back to interpreting them as@formula
specials (i.e., to take the logarithm of an interaction term, uselog(unprotect(a & b))
).
-
-
Various minor but breaking changes in contrast coding: (#273)
-
ContrastsMatrix
can use arbitraryAbstractMatrix
es to store the actual contrasts matrix. -
The number and order of type parameters on
ContrastsMatrix{C,M,T,U}
have changed (fromContrastsMatrix{C,T,U}
), with the addition of the second type parameterM
capturing the type of the contrasts matrix. This is unlikely to affect users but package developers must update anywhere they are specializing onT
orU
(which capture theeltype
of the term names and levels, respectively). -
All
AbstractContrasts
now have keyword argument constructors. -
When constructing
HypothesisCoding
instances, thelabels=
andlevels=
kwargs are now mandatory. -
ContrastsCoding
is no longer exported (previously, a warning was issue that this export is deprecated and is discouraged). -
The un-used
base=
kwarg forSeqDiffCoding
has been removed (previously was a deprecation warning).
-