Open ben-albrecht opened 5 years ago
One potential strategy is to print all information for all dimensions of arrays/iterables and to utilize ellipses to make the output more concise for some arbitrary threshold, e.g.
# Small array
AssertionError: Arrays differ:
1 5 7
!=
1 7 6
Differing elements at 1 index:
2: 5 != 7
# Large array
AssertionError: Arrays differ:
1 5 ... 7 2
!=
1 5 ... 7 2
Differing elements at 12 indices:
4: 1 != 3
8: 2 != 4
...
82: 12 != 9
99: 5 != 7
When an assertion fails for an iterable, such as arrays, lists, tuples, etc., what information should be included in the error message?
The error message information could include some combination of the following:
As of writing this issue, the
UnitTest
module special-cases 1D iterables and prints all of this information:For higher-order arrays, the assertion failure includes the values of all elements:
I think we should choose an error message strategy that:
Note that scaling here refers to the usefulness of the output as the array sizes increase, e.g. outputting the elements of 1Mx1M array is not scalable.