Skip to content

Commit a739df2

Browse files
committed
fix: various method ambiguities
1 parent 5bcf0a7 commit a739df2

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/Expression.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ or `cur_operators` if it is not `nothing`. If left as default,
101101
it requires `cur_operators` to not be `nothing`.
102102
`cur_operators` would typically be an `OperatorEnum`.
103103
"""
104-
function get_operators(ex::AbstractExpression, operators)
104+
function get_operators(
105+
ex::AbstractExpression, operators::Union{AbstractOperatorEnum,Nothing}=nothing
106+
)
105107
return error("`get_operators` function must be implemented for $(typeof(ex)) types.")
106108
end
107109

@@ -110,7 +112,10 @@ end
110112
111113
The same as `operators`, but for variable names.
112114
"""
113-
function get_variable_names(ex::AbstractExpression, variable_names)
115+
function get_variable_names(
116+
ex::AbstractExpression,
117+
variable_names::Union{Nothing,AbstractVector{<:AbstractString}}=nothing,
118+
)
114119
return error(
115120
"`get_variable_names` function must be implemented for $(typeof(ex)) types."
116121
)
@@ -193,7 +198,9 @@ function get_operators(
193198
)
194199
return operators === nothing ? ex.metadata.operators : operators
195200
end
196-
function get_variable_names(ex::Expression, variable_names=nothing)
201+
function get_variable_names(
202+
ex::Expression, variable_names::Union{Nothing,AbstractVector{<:AbstractString}}=nothing
203+
)
197204
return variable_names === nothing ? ex.metadata.variable_names : variable_names
198205
end
199206
function get_tree(ex::Expression)

src/ParametricExpression.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,15 @@ end
142142
get_contents(ex::ParametricExpression) = ex.tree
143143
get_metadata(ex::ParametricExpression) = ex.metadata
144144
get_tree(ex::ParametricExpression) = ex.tree
145-
function get_operators(ex::ParametricExpression, operators=nothing)
145+
function get_operators(
146+
ex::ParametricExpression, operators::Union{AbstractOperatorEnum,Nothing}=nothing
147+
)
146148
return operators === nothing ? ex.metadata.operators : operators
147149
end
148-
function get_variable_names(ex::ParametricExpression, variable_names=nothing)
150+
function get_variable_names(
151+
ex::ParametricExpression,
152+
variable_names::Union{Nothing,AbstractVector{<:AbstractString}}=nothing,
153+
)
149154
return variable_names === nothing ? ex.metadata.variable_names : variable_names
150155
end
151156
@inline _copy_with_nothing(x) = copy(x)
@@ -241,7 +246,10 @@ function eval_tree_array(::ParametricExpression{T}, ::AbstractMatrix{T}, operato
241246
end
242247
#! format: on
243248
function (ex::ParametricExpression)(
244-
X::AbstractMatrix{T}, classes::AbstractVector{<:Integer}, operators=nothing; kws...
249+
X::AbstractMatrix{T},
250+
classes::AbstractVector{<:Integer},
251+
operators::Union{AbstractOperatorEnum,Nothing}=nothing;
252+
kws...,
245253
) where {T}
246254
(output, flag) = eval_tree_array(ex, X, classes, operators; kws...) # Will error
247255
if !flag
@@ -253,7 +261,7 @@ function eval_tree_array(
253261
ex::ParametricExpression{T},
254262
X::AbstractMatrix{T},
255263
classes::AbstractVector{<:Integer},
256-
operators=nothing;
264+
operators::Union{AbstractOperatorEnum,Nothing}=nothing;
257265
kws...,
258266
) where {T}
259267
@assert length(classes) == size(X, 2)

0 commit comments

Comments
 (0)