Skip to content

Commit 99206d7

Browse files
authored
Merge pull request #195 from roland-KA/abstract-tree
Adapt to new `AbstractNode` in `AbstractTrees`
2 parents 9dab9c1 + c65f43b commit 99206d7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ styleguide.txt
33
makefile
44
.DS_Store
55
Manifest.toml
6+
.vscode

src/abstract_trees.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ in "Towards Data Science":
1515
["If things are not ready to use"](https://towardsdatascience.com/part-iii-if-things-are-not-ready-to-use-59d2db378bec)
1616
"""
1717

18-
1918
"""
2019
InfoNode{S, T}
2120
InfoLeaf{T}
@@ -30,15 +29,17 @@ In analogy to the type definitions of `DecisionTree`, the generic type `S` is
3029
the type of the feature values used within a node as a threshold for the splits
3130
between its children and `T` is the type of the classes given (these might be ids or labels).
3231
"""
33-
struct InfoNode{S, T}
32+
struct InfoNode{S, T} <: AbstractTrees.AbstractNode{DecisionTree.Node{S,T}}
3433
node :: DecisionTree.Node{S, T}
3534
info :: NamedTuple
3635
end
36+
AbstractTrees.nodevalue(n::InfoNode) = n.node
3737

38-
struct InfoLeaf{T}
38+
struct InfoLeaf{T} <: AbstractTrees.AbstractNode{DecisionTree.Leaf{T}}
3939
leaf :: DecisionTree.Leaf{T}
4040
info :: NamedTuple
4141
end
42+
AbstractTrees.nodevalue(l::InfoLeaf) = l.leaf
4243

4344
"""
4445
wrap(node::DecisionTree.Node, info = NamedTuple())

0 commit comments

Comments
 (0)