Skip to content

Commit 4ebbfa5

Browse files
committed
Fix tests
1 parent 10a0e00 commit 4ebbfa5

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

test/test_lazynameddimsarrays.jl

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
using AbstractTrees: AbstractTrees, print_tree, printnode
22
using Base.Broadcast: materialize
3-
using ITensorNetworksNext.LazyNamedDimsArrays:
4-
LazyNamedDimsArray, Mul, SymbolicArray, ismul, lazy, substitute, symnameddims
3+
using ITensorNetworksNext.LazyNamedDimsArrays: LazyNamedDimsArrays, LazyNamedDimsArray,
4+
Mul, SymbolicArray, ismul, lazy, substitute, symnameddims
55
using NamedDimsArrays: NamedDimsArray, @names, dename, dimnames, inds, nameddims, namedoneto
6-
using TermInterface:
7-
arguments,
8-
arity,
9-
children,
10-
head,
11-
iscall,
12-
isexpr,
13-
maketerm,
14-
operation,
15-
sorted_arguments,
16-
sorted_children
6+
using TermInterface: arguments, arity, children, head, iscall, isexpr, maketerm, operation,
7+
sorted_arguments, sorted_children
178
using Test: @test, @test_throws, @testset
189
using WrappedUnions: unwrap
1910

2011
@testset "LazyNamedDimsArrays" begin
12+
function sprint_namespaced(x)
13+
context = (:module => LazyNamedDimsArrays)
14+
return sprint(show, MIME"text/plain"(), x; context)
15+
end
2116
@testset "Basics" begin
2217
i, j, k, l = namedoneto.(2, (:i, :j, :k, :l))
2318
a1 = randn(i, j)
@@ -63,8 +58,8 @@ using WrappedUnions: unwrap
6358
@test sprint(show, l1) == sprint(show, a1)
6459
# TODO: Fix this test, it is basically correct but the type parameters
6560
# print in a different way.
66-
# @test sprint(show, MIME"text/plain"(), l1) ==
67-
# replace(sprint(show, MIME"text/plain"(), a1), "NamedDimsArray" => "LazyNamedDimsArray")
61+
# @test sprint_namespaced(l1) ==
62+
# replace(sprint_namespaced(a1), "NamedDimsArray" => "LazyNamedDimsArray")
6863
@test sprint(printnode, l1) == "[:i, :j]"
6964
@test sprint(print_tree, l1) == "[:i, :j]\n"
7065

@@ -82,7 +77,7 @@ using WrappedUnions: unwrap
8277
@test AbstractTrees.children(l) == [l1 * l2, l3]
8378
@test AbstractTrees.nodevalue(l) *
8479
@test sprint(show, l) == "(([:i, :j] * [:j, :k]) * [:k, :l])"
85-
@test sprint(show, MIME"text/plain"(), l) ==
80+
@test sprint_namespaced(l) ==
8681
"named(Base.OneTo(2), :i)×named(Base.OneTo(2), :l) LazyNamedDimsArray{Float64, …}:\n(([:i, :j] * [:j, :k]) * [:k, :l])"
8782
@test sprint(printnode, l) == "(([:i, :j] * [:j, :k]) * [:k, :l])"
8883
@test sprint(print_tree, l) ==
@@ -104,7 +99,7 @@ using WrappedUnions: unwrap
10499
@test arguments(ex) == [a1 * a2, a3]
105100
@test operation(ex) *
106101
@test sprint(show, ex) == "((a1 * a2) * a3)"
107-
@test sprint(show, MIME"text/plain"(), ex) ==
102+
@test sprint_namespaced(ex) ==
108103
"0-dimensional LazyNamedDimsArray{Any, …}:\n((a1 * a2) * a3)"
109104
end
110105

0 commit comments

Comments
 (0)