@@ -517,9 +517,40 @@ function test_IndexAtom()
517517 _test_atom (target) do context
518518 return Variable (2 , 2 )[:, 2 ]
519519 end
520+ # Base.getindex(x::AbstractExpr, I::AbstractVector{Bool})
520521 y = [true , false , true ]
521522 x = Variable (3 )
522- @test string (x[y]) == string ([x[1 ], x[3 ]])
523+ z = x[y]
524+ @test string (z) == string ([x[1 ], x[3 ]])
525+ @test z isa Vector{Convex. IndexAtom}
526+ @test length (z) == 2
527+ Convex. set_value! (x, [1 , 2 , 3 ])
528+ @test Convex. evaluate .(z) == [1 , 3 ]
529+ # Base.getindex(x::AbstractExpr, I::AbstractMatrix{Bool})
530+ y = [true false ; true true ]
531+ x = Variable (2 , 2 )
532+ z = x[y]
533+ @test z isa Vector{Convex. IndexAtom}
534+ @test length (z) == 3
535+ Convex. set_value! (x, [1 3 ; 2 4 ])
536+ @test Convex. evaluate .(z) == [1 , 2 , 4 ]
537+ # Base.getindex(x::AbstractExpr, I::BitVector)
538+ y = BitVector ([true , false , true ])
539+ x = Variable (3 )
540+ z = x[y]
541+ @test string (z) == string ([x[1 ], x[3 ]])
542+ @test z isa Vector{Convex. IndexAtom}
543+ @test length (z) == 2
544+ Convex. set_value! (x, [1 , 2 , 3 ])
545+ @test Convex. evaluate .(z) == [1 , 3 ]
546+ # Base.getindex(x::AbstractExpr, I::BitMatrix)
547+ y = BitMatrix ([true false ; true true ])
548+ x = Variable (2 , 2 )
549+ z = x[y]
550+ @test z isa Vector{Convex. IndexAtom}
551+ @test length (z) == 3
552+ Convex. set_value! (x, [1 3 ; 2 4 ])
553+ @test Convex. evaluate .(z) == [1 , 2 , 4 ]
523554 return
524555end
525556
0 commit comments