@@ -4,7 +4,6 @@ import ..OperatorEnumModule: AbstractOperatorEnum
44import .. UtilsModule: @memoize_on , @with_memoize , deprecate_varmap
55
66const DEFAULT_NODE_TYPE = Float32
7- const FIELD_TYPE = Int16
87
98# ! format: off
109"""
@@ -38,23 +37,23 @@ nodes, you can evaluate or print a given expression.
3837 argument to the binary operator.
3938"""
4039mutable struct Node{T}
41- degree:: FIELD_TYPE # 0 for constant/variable, 1 for cos/sin, 2 for +/* etc.
40+ degree:: Int8 # 0 for constant/variable, 1 for cos/sin, 2 for +/* etc.
4241 constant:: Bool # false if variable
4342 val:: Union{T,Nothing} # If is a constant, this stores the actual value
4443 # ------------------- (possibly undefined below)
45- feature:: FIELD_TYPE # If is a variable (e.g., x in cos(x)), this stores the feature index.
46- op:: FIELD_TYPE # If operator, this is the index of the operator in operators.binary_operators, or operators.unary_operators
44+ feature:: Int16 # If is a variable (e.g., x in cos(x)), this stores the feature index.
45+ op:: Int8 # If operator, this is the index of the operator in operators.binary_operators, or operators.unary_operators
4746 l:: Node{T} # Left child node. Only defined for degree=1 or degree=2.
4847 r:: Node{T} # Right child node. Only defined for degree=2.
4948
5049 # ################
5150 # # Constructors:
5251 # ################
53- Node (d:: Integer , c:: Bool , v:: _T ) where {_T} = new {_T} (FIELD_TYPE (d), c, v)
54- Node (:: Type{_T} , d:: Integer , c:: Bool , v:: _T ) where {_T} = new {_T} (FIELD_TYPE (d), c, v)
55- Node (:: Type{_T} , d:: Integer , c:: Bool , v:: Nothing , f:: Integer ) where {_T} = new {_T} (FIELD_TYPE (d), c, v, FIELD_TYPE (f))
56- Node (d:: Integer , c:: Bool , v:: Nothing , f:: Integer , o:: Integer , l:: Node{_T} ) where {_T} = new {_T} (FIELD_TYPE (d), c, v, FIELD_TYPE (f), FIELD_TYPE (o), l)
57- Node (d:: Integer , c:: Bool , v:: Nothing , f:: Integer , o:: Integer , l:: Node{_T} , r:: Node{_T} ) where {_T} = new {_T} (FIELD_TYPE (d), c, v, FIELD_TYPE (f), FIELD_TYPE (o), l, r)
52+ Node (d:: Integer , c:: Bool , v:: _T ) where {_T} = new {_T} (Int8 (d), c, v)
53+ Node (:: Type{_T} , d:: Integer , c:: Bool , v:: _T ) where {_T} = new {_T} (Int8 (d), c, v)
54+ Node (:: Type{_T} , d:: Integer , c:: Bool , v:: Nothing , f:: Integer ) where {_T} = new {_T} (Int8 (d), c, v, Int16 (f))
55+ Node (d:: Integer , c:: Bool , v:: Nothing , f:: Integer , o:: Integer , l:: Node{_T} ) where {_T} = new {_T} (Int8 (d), c, v, Int16 (f), Int8 (o), l)
56+ Node (d:: Integer , c:: Bool , v:: Nothing , f:: Integer , o:: Integer , l:: Node{_T} , r:: Node{_T} ) where {_T} = new {_T} (Int8 (d), c, v, Int16 (f), Int8 (o), l, r)
5857
5958end
6059# ###############################################################################
@@ -148,11 +147,9 @@ Create a variable node, using a user-passed format
148147"""
149148function Node (var_string:: String , variable_names:: Array{String,1} )
150149 return Node (;
151- feature= FIELD_TYPE (
152- [
153- i for (i, _variable) in enumerate (variable_names) if _variable == var_string
154- ][1 ]:: Int ,
155- ),
150+ feature= [
151+ i for (i, _variable) in enumerate (variable_names) if _variable == var_string
152+ ][1 ]:: Int ,
156153 )
157154end
158155
0 commit comments