(EDIT: fixed incorrect analysis)
Blast from the past – are patches still being accepted for "mrlegacy" code? Something turned up incidentally when working with a customer that looks like a minor bug in the cluster dumper code.
The problem is that this never outputs any elements of a vector with value 0, but, also doesn't print indices in some cases. This means the output is smaller than the number of dimensions, but it's not possible to know where the omitted 0s are.
It will not output indices if the vector is a dense vector, or if the number of non-default elements is the same as the size (which includes sparse vectors even containing 0 values, if they have been set explicitly). However the iteration is over non-zero elements only.
The fix seems to be to print indices if the number of non-zero elements is less than size, for any vector:
Pretty straightforward, and minor, but wanted to check with everyone before making a change.