Skip to content

Commit

Permalink
fix cutoff lookup (#16)
Browse files Browse the repository at this point in the history
- use a function that gets the composite type for indexing the lookup tuple even when used in a module.
- issues like these are a convincing argument against this kind of backend... I should drop the lookup tables in another release!
  • Loading branch information
simonsteiger authored Aug 15, 2024
1 parent 2dc8b17 commit cae8022
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/functions/categorise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ julia> categorise(SDAI, 3.6)
```
"""
function categorise(::Type{T}, s::Real) where {T<:ContinuousComposite}
return seq_check(s, getproperty(cont_cutoff_funs, Symbol(T)))
return seq_check(s, getproperty(cont_cutoff_funs, _typename(T)))
end
# This implementation is roughly half as 2.5 times slower than hard coding
# cutoffs into each categorise function
Expand Down
4 changes: 3 additions & 1 deletion src/functions/isremission.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
_typename(x::DataType) = Symbol(split(string(nameof(x)), ".")[end])

function isremission(::Type{T}, x::AbstractComposite) where {T<:ContinuousComposite}
cut = getproperty(cont_cutoff_funs, Symbol(T))
cut = getproperty(cont_cutoff_funs, _typename(T))
return cut.remission(score(x))
end

Expand Down
2 changes: 2 additions & 0 deletions src/utils/auxfuns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function values_flatten(x::NamedTuple)
return property_vec
end

_typename(x::DataType) = Symbol(split(string(nameof(x)), ".")[end])

function seq_check(x::Real, conds::NamedTuple)
funs = values(conds)
i = 1
Expand Down

0 comments on commit cae8022

Please sign in to comment.