Skip to content

Commit

Permalink
fix #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Apr 18, 2019
1 parent 31d7252 commit 28ae52d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/composite/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ chain(list::Vector) = ChainBlock(list)
# if not all matrix block, try to put the number of qubits.
chain(n::Int, blocks...) = chain(map(x->parse_block(n, x), blocks)...)
chain(n::Int, itr) = chain(map(x->parse_block(n, x), itr)...)
chain(n::Int, f::Function) = chain(n, parse_block(n, f))
function chain(n::Int, block::AbstractBlock)
@assert n == nqubits(block) "number of qubits mismatch"
return ChainBlock(block)
Expand Down
3 changes: 3 additions & 0 deletions test/composite/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ end
@test chain(control(4, 2, 1=>X), kron(4, 1=>X)) |> nqubits == 4
end

@testset "#15" begin
@test chain(4, n->kron(n, 1=>H)) isa ChainBlock
end

@testset "test operations" begin
g = ChainBlock(
Expand Down

0 comments on commit 28ae52d

Please sign in to comment.