<commit_before>abstract Tree{T}
abstract Node{T}
abstract Branch{T} <: Node{T}
abstract Leaf{T}   <: Node{T}

function valid_tree{T}(tree::Tree{T})
    @assert typeof(tree.root)<: Node
    @assert valid_node(tree.root)
    true
end

function valid_node{T}(branch::Branch{T})
    @assert valid_node(branch.left)
    @assert valid_node(branch.right)
    @assert typeof(branch.feature) <: Int
    @assert typeof(branch.value)   <: Float64
    true
end

function valid_node{T}(leaf::Leaf{T})
    @assert typeof(leaf.value) <: Float64
    true
end

depth{T}(tree::Tree{T})     = depth(tree.root)
depth{T}(branch::Branch{T}) = 1 + max(depth(branch.left), depth(branch.right))
depth{T}(leaf::Leaf{T})     = 1

Base.length{T}(tree::Tree{T})     = length(tree.root)
Base.length{T}(branch::Branch{T}) = 1 + length(branch.left) + length(branch.right)
Base.length{T}(leaf::Leaf{T})     = 1<commit_msg>removed constraint on leaf structure<commit_after>abstract Tree{T}
abstract Node{T}
abstract Branch{T} <: Node{T}
abstract Leaf{T}   <: Node{T}

function valid_tree{T}(tree::Tree{T})
    @assert typeof(tree.root)<: Node
    @assert valid_node(tree.root)
    true
end

function valid_node{T}(branch::Branch{T})
    @assert valid_node(branch.left)
    @assert valid_node(branch.right)
    @assert typeof(branch.feature) <: Int
    @assert typeof(branch.value)   <: Float64
    true
end

function valid_node{T}(leaf::Leaf{T})
    true
end

depth{T}(tree::Tree{T})     = depth(tree.root)
depth{T}(branch::Branch{T}) = 1 + max(depth(branch.left), depth(branch.right))
depth{T}(leaf::Leaf{T})     = 1

Base.length{T}(tree::Tree{T})     = length(tree.root)
Base.length{T}(branch::Branch{T}) = 1 + length(branch.left) + length(branch.right)
Base.length{T}(leaf::Leaf{T})     = 1
{'fraction_non_alphanumeric': 0.17851051733939738, 'fraction_numerical': 0.007959067652075043, 'mean_word_length': 4.945945945945946, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7502882', 'n_tokens_mistral': 658, 'n_tokens_neox': 649, 'n_words': 112}