File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 396
396
# get(::ModelLike, ::AbstractVariableAttribute, ::Vector{VariableIndex})
397
397
# would not allow us to define get(::SomeModel, ::AnyAttribute, ::Vector).
398
398
function get (model:: ModelLike , attr:: AnyAttribute , idxs:: Vector )
399
+ if isempty (idxs)
400
+ return Vector {attribute_value_type(attr)} ()
401
+ end
399
402
return get .(model, attr, idxs)
400
403
end
401
404
Original file line number Diff line number Diff line change @@ -316,6 +316,23 @@ function test_attributes_AutomaticDifferentiationBackend()
316
316
return
317
317
end
318
318
319
+ function test_empty_vector_attribute ()
320
+ model = MOI. Utilities. Model {Float64} ()
321
+ x = MOI. get (model, MOI. ListOfVariableIndices ())
322
+ @test typeof (x) == Vector{MOI. VariableIndex}
323
+ ret = MOI. get (model, MOI. VariablePrimalStart (), x)
324
+ @test typeof (ret) == Vector{Any}
325
+ ret = MOI. get (model, MOI. VariableName (), x)
326
+ @test typeof (ret) == Vector{String}
327
+ F, S = MOI. ScalarAffineFunction{Float64}, MOI. EqualTo{Float64}
328
+ c = MOI. get (model, MOI. ListOfConstraintIndices {F,S} ())
329
+ ret = MOI. get (model, MOI. ConstraintPrimalStart (), c)
330
+ @test typeof (ret) == Vector{Any}
331
+ ret = MOI. get (model, MOI. ConstraintName (), c)
332
+ @test typeof (ret) == Vector{String}
333
+ return
334
+ end
335
+
319
336
function runtests ()
320
337
for name in names (@__MODULE__ ; all = true )
321
338
if startswith (" $name " , " test_" )
You can’t perform that action at this time.
0 commit comments