Skip to content

Ellipsis not shown when setMaxNumReportedItems(1,1) #588

@TysonRayJones

Description

@TysonRayJones

Example isolated/reporting_matrices.c (formerly reporters/matrices.c) demonstrates the issue:

>> set number of reported items to 5

CompMatr (4 qubits, 16x16 qcomps, 4.06 KiB):
    1    2    3    …  15   16
    17   18   19   …  31   32
    33   34   35   …  47   48
     ⋮
    225  226  227  …  239  240
    241  242  243  …  255  256
>> set number of reported items to 1

CompMatr (4 qubits, 16x16 qcomps, 4.06 KiB):
    1

whereas a user might expect the latter to print

CompMatr (4 qubits, 16x16 qcomps, 4.06 KiB):
    1 …
    ⋮

That is, when the number of reported items is strictly 1, the truncated elements are not divided into left/right (or up/down) partitions. The latter partition is empty. So no ellipsis are reported, incorrectly suggesting the structure (matrix, list, qureg) has only one element and was not truncated.

This could be corrected by extending the logic of printer.cpp function printMatrixInFourQuadrants() to accept an additional parameter to force ellipsis when the right/down partitions are empty. But this is a big inelegance for this extremely narrow (and a bit ridiculous) use-case; when the user sets the maximum items to 1.

We could instead forbid this scenario; restrict users from supplying items=1, so that the valid domain is {0} U [2, inf). This seems a little unnatural and an unexpected pitfall, since the user could reason what should simply happen when passing items=1 (the current reporting but with ellipsis).

Decide what to do and fix!

Note that in v4 (rather than impending version v4.1), one more lower/right partition items are printed (than left/upper) when items=odd. This causes a segmentation fault when items=1 because of this line. This is a much more critical issue than the incomplete printing and has been patched.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions