Skip to content

Commit 3d64032

Browse files
committed
Add JET comments
1 parent a8ce667 commit 3d64032

File tree

8 files changed

+19
-1
lines changed

8 files changed

+19
-1
lines changed

src/Bridges/Constraint/bridges/IntegerToZeroOneBridge.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function MOI.Bridges.final_touch(
152152
bridge::IntegerToZeroOneBridge{T},
153153
model::MOI.ModelLike,
154154
) where {T}
155+
# Type annotation needed for JET
155156
ret = MOI.Utilities.get_bounds(model, T, bridge.x)::Tuple{T,T}
156157
if ret === bridge.last_bounds
157158
return nothing # final_touch already called

src/FileFormats/LP/read.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ end
511511

512512
_is_number(c::Char) = isdigit(c) || c in ('.', 'e', 'E', '+', '-')
513513

514+
function _is_negative_digit(state, c)
515+
# The type annotation is needed for JET.
516+
return c == '-' && isdigit(peek(state, Char)::Char)
517+
end
518+
514519
function _peek_inner(state::_LexerState)
515520
while (c = peek(state, Char)) !== nothing
516521
pos = position(state.io)
@@ -523,7 +528,7 @@ function _peek_inner(state::_LexerState)
523528
while (c = peek(state, Char)) !== nothing && c != '\n'
524529
_ = read(state, Char)
525530
end
526-
elseif isdigit(c) || (c == '-' && isdigit(peek(state, Char)::Char)) # Number
531+
elseif isdigit(c) || _is_negative_digit(state, c) # Number
527532
buf = IOBuffer()
528533
while (c = peek(state, Char)) !== nothing && _is_number(c)
529534
write(buf, c)
@@ -826,6 +831,7 @@ function _parse_term(
826831
# <quadratic-expression>
827832
return _parse_quadratic_expression(state, cache, prefix)
828833
end
834+
# The type annotation is needed for JET.
829835
token = peek(state, _Token)::_Token
830836
return _throw_parse_error(
831837
state,
@@ -1050,6 +1056,7 @@ function _parse_constraint_sos(
10501056
f, w = MOI.VectorOfVariables(MOI.VariableIndex[]), T[]
10511057
while true
10521058
if _next_token_is(state, _TOKEN_NEWLINE)
1059+
# The type annotation is needed for JET.
10531060
t = peek(state, _Token)::_Token
10541061
_throw_parse_error(
10551062
state,
@@ -1096,6 +1103,7 @@ function _parse_constraint_indicator(
10961103
end
10971104
_ = read(state, _Token, _TOKEN_IMPLIES)
10981105
f = _parse_expression(state, cache)
1106+
# The type annotation is needed for JET.
10991107
set = _parse_set_suffix(state, cache)::MOI.AbstractScalarSet
11001108
return MOI.add_constraint(
11011109
cache.model,
@@ -1117,6 +1125,7 @@ function _parse_constraint(state::_LexerState, cache::_ReadCache)
11171125
_parse_constraint_indicator(state, cache)
11181126
else
11191127
f = _parse_expression(state, cache)
1128+
# The type annotation is needed for JET.
11201129
set = _parse_set_suffix(state, cache)::MOI.AbstractScalarSet
11211130
MOI.add_constraint(cache.model, f, set)
11221131
end

src/FileFormats/MPS/read.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ function _add_indicator_constraint(
432432
scalar = MOI.ScalarAffineTerm(coef, variable_map[data.col_to_name[i]])
433433
push!(terms, MOI.VectorAffineTerm(2, scalar))
434434
end
435+
# The type annotation is needed for JET.
435436
f = MOI.VectorAffineFunction(terms, zeros(T, 2)::Vector{T})
436437
c = MOI.add_constraint(model, f, MOI.Indicator{activate}(set))
437438
MOI.set(model, MOI.ConstraintName(), c, c_name)

src/FileFormats/NL/read.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,14 @@ _try_scalar_affine_function(x::MOI.VariableIndex) = x
271271
function _try_scalar_affine_function(expr::Expr)
272272
if expr.args[1] == :+
273273
args = _try_scalar_affine_function.(expr.args[2:end])
274+
# The type annotation is needed for JET.
274275
if any(isnothing, args)::Bool
275276
return nothing
276277
end
277278
return MOI.Utilities.operate(+, Float64, args...)
278279
elseif expr.args[1] == :*
279280
args = _try_scalar_affine_function.(expr.args[2:end])
281+
# The type annotation is needed for JET.
280282
if any(isnothing, args)::Bool
281283
return nothing
282284
end

src/Nonlinear/SymbolicAD/SymbolicAD.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ function Evaluator(
13351335
if model.objective !== nothing
13361336
o_sym = _to_symbolic_form(
13371337
model,
1338+
# The type annotation is needed for JET.
13381339
model.objective::MOI.Nonlinear.Expression,
13391340
variable_to_column,
13401341
)

src/Test/test_conic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,7 @@ function _test_conic_RotatedSecondOrderCone_helper(
21752175
MOI.RotatedSecondOrderCone,
21762176
)
21772177
end
2178+
# These variables are needed for JET.
21782179
vc1, vc2 = nothing, nothing
21792180
if abvars
21802181
abx, rsoc =
@@ -5939,6 +5940,7 @@ function _test_det_cone_helper_ellipsoid(
59395940
@test MOI.get(model, MOI.NumberOfVariables()) == 1
59405941
Q = MOI.add_variables(model, square ? 4 : 3)
59415942
@test MOI.get(model, MOI.NumberOfVariables()) == (square ? 5 : 4)
5943+
# These variables are needed for JET.
59425944
u, vc = nothing, nothing
59435945
if use_logdet
59445946
u = MOI.add_variable(model)

src/Utilities/distance_to_set.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ function _reshape(
509509
set::MOI.PositiveSemidefiniteConeTriangle,
510510
) where {T}
511511
n = MOI.side_dimension(set)
512+
# The type annotation is needed for JET.
512513
X = zeros(T, n, n)::Matrix{T}
513514
k = 1
514515
for i in 1:n

src/Utilities/model.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ function MOI.get(model::AbstractModel, ::Type{MOI.VariableIndex}, name::String)
295295
if model.name_to_var === nothing
296296
model.name_to_var = build_name_to_var_map(model.var_to_name)
297297
end
298+
# The type annotation is needed for JET.
298299
result =
299300
get(model.name_to_var::Dict{String,MOI.VariableIndex}, name, nothing)
300301
throw_if_multiple_with_name(result, name)

0 commit comments

Comments
 (0)