Skip to content

Commit a2d212f

Browse files
committed
tuplemortar with nested tuple input
1 parent bfc6554 commit a2d212f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/blockedtuple.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct BlockedTuple{BlockLengths,Flat} <: AbstractBlockTuple
9292
end
9393

9494
# TensorAlgebra Interface
95-
tuplemortar(tt::Vararg{Tuple}) = BlockedTuple{length.(tt)}(flatten_tuples(tt))
95+
tuplemortar(tt::Tuple{Vararg{Tuple}}) = BlockedTuple{length.(tt)}(flatten_tuples(tt))
9696
function BlockedTuple(flat::Tuple, BlockLengths::Tuple{Vararg{Int}})
9797
return BlockedTuple{BlockLengths}(flat)
9898
end

test/test_blockedtuple.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using TensorAlgebra: BlockedTuple, tuplemortar
1212
bt = BlockedTuple{divs}(flat)
1313

1414
@test (@constinferred Tuple(bt)) == flat
15-
@test bt == tuplemortar((true,), ('a', 2), ("b", 3.0))
15+
@test bt == tuplemortar(((true,), ('a', 2), ("b", 3.0)))
1616
@test bt == BlockedTuple(flat, divs)
1717
@test BlockedTuple(bt) == bt
1818
@test blocklength(bt) == 3
@@ -25,7 +25,7 @@ using TensorAlgebra: BlockedTuple, tuplemortar
2525
# it is hard to make bt[Block(1)] type stable as compile-time knowledge of 1 is lost in Block
2626
@test bt[Block(1)] == blocks(bt)[1]
2727
@test bt[Block(2)] == blocks(bt)[2]
28-
@test bt[Block(1):Block(2)] == tuplemortar((true,), ('a', 2))
28+
@test bt[Block(1):Block(2)] == tuplemortar(((true,), ('a', 2)))
2929
@test bt[Block(2)[1:2]] == ('a', 2)
3030
@test bt[2:4] == ('a', 2, "b")
3131

@@ -39,17 +39,17 @@ using TensorAlgebra: BlockedTuple, tuplemortar
3939

4040
@test_throws DimensionMismatch BlockedTuple{(1, 2, 3)}(flat)
4141

42-
bt = tuplemortar((1,), (4, 2), (5, 3))
42+
bt = tuplemortar(((1,), (4, 2), (5, 3)))
4343
@test Tuple(bt) == (1, 4, 2, 5, 3)
4444
@test blocklengths(bt) == (1, 2, 2)
4545
@test deepcopy(bt) == bt
4646

4747
@test (@constinferred map(n -> n + 1, bt)) ==
4848
BlockedTuple{blocklengths(bt)}(Tuple(bt) .+ 1)
49-
@test bt .+ tuplemortar((1,), (1, 1), (1, 1)) ==
49+
@test bt .+ tuplemortar(((1,), (1, 1), (1, 1))) ==
5050
BlockedTuple{blocklengths(bt)}(Tuple(bt) .+ 1)
51-
@test_throws DimensionMismatch bt .+ tuplemortar((1, 1), (1, 1), (1,))
51+
@test_throws DimensionMismatch bt .+ tuplemortar(((1, 1), (1, 1), (1,)))
5252

53-
bt = tuplemortar((1:2, 1:2), (1:3,))
54-
@test length.(bt) == tuplemortar((2, 2), (3,))
53+
bt = tuplemortar(((1:2, 1:2), (1:3,)))
54+
@test length.(bt) == tuplemortar(((2, 2), (3,)))
5555
end

0 commit comments

Comments
 (0)