Skip to content

Commit 3af9f28

Browse files
authored
Update test_atoms.jl
1 parent 52fc1f9 commit 3af9f28

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

test/test_atoms.jl

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,18 +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-
target = """
524-
variables: x1, x2, x3
525-
minobjective: [1.0 * x1, 1.0 * x3]
526-
"""
527-
_test_atom(target) do context
528-
x = Variable(3)
529-
y = BitVector([true, false, true])
530-
return x[y]
531-
end
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]
532554
return
533555
end
534556

0 commit comments

Comments
 (0)