Skip to content

Commit 408a4a5

Browse files
committed
Fix up other uses of old types
1 parent 807400b commit 408a4a5

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

docs/src/eval.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ all variables (or, all constants). Both use forward-mode automatic, but use
9090
`Zygote.jl` to compute derivatives of each operator, so this is very efficient.
9191

9292
```@docs
93-
eval_diff_tree_array(tree::Node{T}, cX::AbstractMatrix{T}, operators::OperatorEnum, direction::Int) where {T<:Number}
93+
eval_diff_tree_array(tree::Node{T}, cX::AbstractMatrix{T}, operators::OperatorEnum, direction::Integer) where {T<:Number}
9494
eval_grad_tree_array(tree::Node{T}, cX::AbstractMatrix{T}, operators::OperatorEnum; turbo::Bool=false, variable::Bool=false) where {T<:Number}
9595
```
9696

docs/src/types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ There are a variety of constructors for `Node` objects, including:
5555

5656
```@docs
5757
Node(::Type{T}; val=nothing, feature::Integer=nothing) where {T}
58-
Node(op::Int, l::Node)
59-
Node(op::Int, l::Node, r::Node)
58+
Node(op::Integer, l::Node)
59+
Node(op::Integer, l::Node, r::Node)
6060
Node(var_string::String)
6161
```
6262

ext/DynamicExpressionsSymbolicUtilsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function multiply_powers(
228228
@return_on_false complete eqn
229229
@return_on_false isgood(l) eqn
230230
n = args[2]
231-
if typeof(n) <: Int
231+
if typeof(n) <: Integer
232232
if n == 1
233233
return l, true
234234
elseif n == -1

src/Equation.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ nodes, you can evaluate or print a given expression.
1616
1717
# Fields
1818
19-
- `degree::Int`: Degree of the node. 0 for constants, 1 for
19+
- `degree::Int8`: Degree of the node. 0 for constants, 1 for
2020
unary operators, 2 for binary operators.
2121
- `constant::Bool`: Whether the node is a constant.
2222
- `val::T`: Value of the node. If `degree==0`, and `constant==true`,
2323
this is the value of the constant. It has a type specified by the
2424
overall type of the `Node` (e.g., `Float64`).
25-
- `feature::Int` (optional): Index of the feature to use in the
25+
- `feature::Int16` (optional): Index of the feature to use in the
2626
case of a feature node. Only used if `degree==0` and `constant==false`.
2727
Only defined if `degree == 0 && constant == false`.
28-
- `op::Int`: If `degree==1`, this is the index of the operator
28+
- `op::Int8`: If `degree==1`, this is the index of the operator
2929
in `operators.unaops`. If `degree==2`, this is the index of the
3030
operator in `operators.binops`. In other words, this is an enum
3131
of the operators, and is dependent on the specific `OperatorEnum`
@@ -62,7 +62,7 @@ end
6262
include("base.jl")
6363

6464
"""
65-
Node([::Type{T}]; val=nothing, feature::Int=nothing) where {T}
65+
Node([::Type{T}]; val=nothing, feature::Union{Integer,Nothing}=nothing) where {T}
6666
6767
Create a leaf node: either a constant, or a variable.
6868
@@ -112,14 +112,14 @@ function Node(
112112
end
113113

114114
"""
115-
Node(op::Int, l::Node)
115+
Node(op::Integer, l::Node)
116116
117117
Apply unary operator `op` (enumerating over the order given) to `Node` `l`
118118
"""
119119
Node(op::Integer, l::Node{T}) where {T} = Node(1, false, nothing, 0, op, l)
120120

121121
"""
122-
Node(op::Int, l::Node, r::Node)
122+
Node(op::Integer, l::Node, r::Node)
123123
124124
Apply binary operator `op` (enumerating over the order given) to `Node`s `l` and `r`
125125
"""
@@ -138,7 +138,7 @@ end
138138
139139
Create a variable node, using the format `"x1"` to mean feature 1
140140
"""
141-
Node(var_string::String) = Node(; feature=parse(Int, var_string[2:end]))
141+
Node(var_string::String) = Node(; feature=parse(Int16, var_string[2:end]))
142142

143143
"""
144144
Node(var_string::String, variable_names::Array{String, 1})
@@ -258,7 +258,7 @@ Convert an equation to a string.
258258
259259
# Keyword Arguments
260260
- `bracketed`: (optional) whether to put brackets around the outside.
261-
- `f_variable`: (optional) function to convert a variable to a string, of the form `(feature::Int, variable_names)`.
261+
- `f_variable`: (optional) function to convert a variable to a string, of the form `(feature::Int8, variable_names)`.
262262
- `f_constant`: (optional) function to convert a constant to a string, of the form `(val, bracketed::Bool)`
263263
- `variable_names::Union{Array{String, 1}, Nothing}=nothing`: (optional) what variables to print for each feature.
264264
"""

src/EquationUtils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ end
9292
# This will mirror a Node struct, rather
9393
# than adding a new attribute to Node.
9494
mutable struct NodeIndex
95-
constant_index::Int # Index of this constant (if a constant exists here)
95+
constant_index::Int16 # Index of this constant (if a constant exists here)
9696
l::NodeIndex
9797
r::NodeIndex
9898

@@ -103,14 +103,14 @@ function index_constants(tree::Node)::NodeIndex
103103
return index_constants(tree, 0)
104104
end
105105

106-
function index_constants(tree::Node, left_index::Int)::NodeIndex
106+
function index_constants(tree::Node, left_index::Int16)::NodeIndex
107107
index_tree = NodeIndex()
108108
index_constants!(tree, index_tree, left_index)
109109
return index_tree
110110
end
111111

112112
# Count how many constants to the left of this node, and put them in a tree
113-
function index_constants!(tree::Node, index_tree::NodeIndex, left_index::Int)
113+
function index_constants!(tree::Node, index_tree::NodeIndex, left_index::Int16)
114114
if tree.degree == 0
115115
if tree.constant
116116
index_tree.constant_index = left_index + 1

src/EvaluateEquationDerivative.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function assert_autodiff_enabled(operators::OperatorEnum)
1818
end
1919

2020
"""
21-
eval_diff_tree_array(tree::Node{T}, cX::AbstractMatrix{T}, operators::OperatorEnum, direction::Int; turbo::Bool=false)
21+
eval_diff_tree_array(tree::Node{T}, cX::AbstractMatrix{T}, operators::OperatorEnum, direction::Integer; turbo::Bool=false)
2222
2323
Compute the forward derivative of an expression, using a similar
2424
structure and optimization to eval_tree_array. `direction` is the index of a particular
@@ -31,7 +31,7 @@ respect to `x1`.
3131
- `cX::AbstractMatrix{T}`: The data matrix, with each column being a data point.
3232
- `operators::OperatorEnum`: The operators used to create the `tree`. Note that `operators.enable_autodiff`
3333
must be `true`. This is needed to create the derivative operations.
34-
- `direction::Int`: The index of the variable to take the derivative with respect to.
34+
- `direction::Integer`: The index of the variable to take the derivative with respect to.
3535
- `turbo::Bool`: Use `LoopVectorization.@turbo` for faster evaluation.
3636
3737
# Returns
@@ -43,7 +43,7 @@ function eval_diff_tree_array(
4343
tree::Node{T},
4444
cX::AbstractMatrix{T},
4545
operators::OperatorEnum,
46-
direction::Int;
46+
direction::Integer;
4747
turbo::Bool=false,
4848
)::Tuple{AbstractVector{T},AbstractVector{T},Bool} where {T<:Number}
4949
assert_autodiff_enabled(operators)
@@ -57,7 +57,7 @@ function eval_diff_tree_array(
5757
tree::Node{T1},
5858
cX::AbstractMatrix{T2},
5959
operators::OperatorEnum,
60-
direction::Int;
60+
direction::Integer;
6161
turbo::Bool=false,
6262
) where {T1<:Number,T2<:Number}
6363
T = promote_type(T1, T2)
@@ -71,7 +71,7 @@ function _eval_diff_tree_array(
7171
tree::Node{T},
7272
cX::AbstractMatrix{T},
7373
operators::OperatorEnum,
74-
direction::Int,
74+
direction::Integer,
7575
::Val{turbo},
7676
)::Tuple{AbstractVector{T},AbstractVector{T},Bool} where {T<:Number,turbo}
7777
evaluation, derivative, complete = if tree.degree == 0
@@ -102,7 +102,7 @@ function _eval_diff_tree_array(
102102
end
103103

104104
function diff_deg0_eval(
105-
tree::Node{T}, cX::AbstractMatrix{T}, direction::Int
105+
tree::Node{T}, cX::AbstractMatrix{T}, direction::Integer
106106
)::Tuple{AbstractVector{T},AbstractVector{T},Bool} where {T<:Number}
107107
const_part = deg0_eval(tree, cX)[1]
108108
derivative_part = if ((!tree.constant) && tree.feature == direction)
@@ -119,7 +119,7 @@ function diff_deg1_eval(
119119
op::F,
120120
diff_op::dF,
121121
operators::OperatorEnum,
122-
direction::Int,
122+
direction::Integer,
123123
::Val{turbo},
124124
)::Tuple{AbstractVector{T},AbstractVector{T},Bool} where {T<:Number,F,dF,turbo}
125125
(cumulator, dcumulator, complete) = _eval_diff_tree_array(
@@ -144,7 +144,7 @@ function diff_deg2_eval(
144144
op::F,
145145
diff_op::dF,
146146
operators::OperatorEnum,
147-
direction::Int,
147+
direction::Integer,
148148
::Val{turbo},
149149
)::Tuple{AbstractVector{T},AbstractVector{T},Bool} where {T<:Number,F,dF,turbo}
150150
(cumulator, dcumulator, complete) = _eval_diff_tree_array(

src/OperatorEnumConstruction.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ end
1919

2020
const LATEST_OPERATORS = Ref{Union{Nothing,AbstractOperatorEnum}}(nothing)
2121
const LATEST_OPERATORS_TYPE = Ref{AvailableOperatorTypes}(IsNothing)
22-
const LATEST_UNARY_OPERATOR_MAPPING = Dict{Function,Int}()
23-
const LATEST_BINARY_OPERATOR_MAPPING = Dict{Function,Int}()
22+
const LATEST_UNARY_OPERATOR_MAPPING = Dict{Function,Int8}()
23+
const LATEST_BINARY_OPERATOR_MAPPING = Dict{Function,Int8}()
2424
const ALREADY_DEFINED_UNARY_OPERATORS = (;
2525
operator_enum=Dict{Function,Bool}(), generic_operator_enum=Dict{Function,Bool}()
2626
)

src/base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ julia> tree_mapreduce(t -> 1, (p, c...) -> p + max(c...), tree) # compute depth
5252
5
5353
5454
julia> tree_mapreduce(vcat, tree) do t
55-
t.degree == 2 ? [t.op] : Int[]
55+
t.degree == 2 ? [t.op] : Int8[]
5656
end # Get list of binary operators used. (regular mapreduce also works)
57-
2-element Vector{Int64}:
57+
2-element Vector{Int8}:
5858
1
5959
2
6060

test/test_base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ end
114114
@test length(unique(map(objectid, copy_node(tree; preserve_sharing=true)))) == 24 - 3
115115
map(t -> (t.degree == 0 && t.constant) ? (t.val *= 2) : nothing, ctree)
116116
@test sum(t -> t.val, filter(t -> t.degree == 0 && t.constant, ctree)) == 11.6 * 2
117-
@test typeof(map(t -> t.degree, ctree, Int)) == Vector{Int}
118-
@test first(map(t -> t.degree, ctree, Int)) == 2
117+
@test typeof(map(t -> t.degree, ctree, Int8)) == Vector{Int8}
118+
@test first(map(t -> t.degree, ctree, Int8)) == 2
119119
end
120120

121121
@testset "in" begin

0 commit comments

Comments
 (0)