Skip to content

Commit

Permalink
fix assert; update basisname.jl
Browse files Browse the repository at this point in the history
fixes the assert in predict.jl to make sure partial overlap is not done on models with only one formula. Additionally adds basisname function for uf::UnfoldLinearModel
  • Loading branch information
ReneSkukies committed Sep 16, 2024
1 parent 1161b87 commit 7b0ed6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/basisfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ kernel(basis::BasisFunction, e) = basis.kernel(e)

basisname(fs::Vector{<:FormulaTerm}) = [name(f.rhs.basisfunction) for f in fs]
basisname(uf::UnfoldModel) = basisname(formulas(uf))
basisname(uf::UnfoldLinearModel) = first.(design(uf)) # for linear models we dont save it in the formula

kernel(basis::FIRBasis, e) =
basis.interpolate ? firkernel(e, basis.times[1:end-1]; interpolate = true) :
Expand Down
6 changes: 3 additions & 3 deletions src/predict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ function predict(
kwargs...,
#eventcolumn = :event,
)
@assert (
(!isempty(keep_basis) | !isempty(exclude_basis)) &
(basisname(Unfold.formulas(uf))[1] == Any)
@assert !(
(!isempty(keep_basis) || !isempty(exclude_basis)) &&
(length(formulas(uf)) == 1)
) "No way to calculate partial overlap if basisnames is Any; please revise model "

@assert !(!isempty(keep_basis) & !isempty(exclude_basis)) "choose either to keep events, or to exclude, but not both"
Expand Down

0 comments on commit 7b0ed6d

Please sign in to comment.