Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 3, 2018
1 parent b9bd775 commit d4a0398
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/matmeasure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@ end

Base.size(Q::SymMatrix) = (Q.n, Q.n)

function Base.getindex(Q::SymMatrix, i, j)
function Base.getindex(Q::SymMatrix, i::Integer, j::Integer)
Q.Q[trimap(max(i, j), min(i, j))]
end
function Base.getindex(Q::SymMatrix, k)
i, j = divrem(k-1, Q.n)
Q[i+1, j+1]
end
Base.getindex(Q::SymMatrix, I::Tuple) = Q[I...]
Base.getindex(Q::SymMatrix, I::CartesianIndex) = Q[I.I]

Expand Down
11 changes: 5 additions & 6 deletions test/matmeasure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
μ = measure(1:3, [x^2, x*y, y^2])
X = [x, y]
for ν in (matmeasure(μ, X), matmeasure((i, j) -> i + j - 1, X))
Q = getmat(ν)
@test Q[1:4] == [1, 2, 2, 3]
@test Q[1, 1] == 1
@test Q[1, 2] == 2
@test Q[2, 1] == 2
@test Q[2, 2] == 3
@test ν.Q[1:4] == [1, 2, 2, 3]
@test ν.Q[1, 1] == 1
@test ν.Q[1, 2] == 2
@test ν.Q[2, 1] == 2
@test ν.Q[2, 2] == 3
@test variables(ν)[1] == x
@test variables(ν)[2] == y
@test nvariables(ν) == 2
Expand Down

0 comments on commit d4a0398

Please sign in to comment.