|
624 | 624 | end |
625 | 625 | end |
626 | 626 | end |
| 627 | + |
| 628 | +@timedtestset "show tensors" begin |
| 629 | + for V in (ℂ^2, Z2Space(0 => 2, 1 => 2), SU2Space(0 => 2, 1 => 2)) |
| 630 | + t1 = ones(Float32, V ⊗ V, V) |
| 631 | + t2 = randn(ComplexF64, V ⊗ V ⊗ V) |
| 632 | + # test unlimited output |
| 633 | + for t in (t1, t2, t1', t2') |
| 634 | + output = IOBuffer() |
| 635 | + summary(output, t) |
| 636 | + print(output, ":\n codomain: ") |
| 637 | + show(output, MIME("text/plain"), codomain(t)) |
| 638 | + print(output, "\n domain: ") |
| 639 | + show(output, MIME("text/plain"), domain(t)) |
| 640 | + print(output, "\n blocks: \n") |
| 641 | + first = true |
| 642 | + for (c, b) in blocks(t) |
| 643 | + first || print(output, "\n\n") |
| 644 | + print(output, " * ") |
| 645 | + show(output, MIME("text/plain"), c) |
| 646 | + print(output, " => ") |
| 647 | + show(output, MIME("text/plain"), b) |
| 648 | + first = false |
| 649 | + end |
| 650 | + outputstr = String(take!(output)) |
| 651 | + @test outputstr == sprint(show, MIME("text/plain"), t) |
| 652 | + end |
| 653 | + |
| 654 | + # test limited output with a single block |
| 655 | + t = randn(Float64, V ⊗ V, V)' # we know there is a single space in the codomain, so that blocks have 2 rows |
| 656 | + output = IOBuffer() |
| 657 | + summary(output, t) |
| 658 | + print(output, ":\n codomain: ") |
| 659 | + show(output, MIME("text/plain"), codomain(t)) |
| 660 | + print(output, "\n domain: ") |
| 661 | + show(output, MIME("text/plain"), domain(t)) |
| 662 | + print(output, "\n blocks: \n") |
| 663 | + c = unit(sectortype(t)) |
| 664 | + b = block(t, c) |
| 665 | + print(output, " * ") |
| 666 | + show(output, MIME("text/plain"), c) |
| 667 | + print(output, " => ") |
| 668 | + show(output, MIME("text/plain"), b) |
| 669 | + if length(blocks(t)) > 1 |
| 670 | + print(output, "\n\n * … [output of 1 more block(s) truncated]") |
| 671 | + end |
| 672 | + outputstr = String(take!(output)) |
| 673 | + @test outputstr == sprint(show, MIME("text/plain"), t; context = (:limit => true, :displaysize => (12, 100))) |
| 674 | + end |
| 675 | +end |
0 commit comments