format_minimal

glue.utils.array.format_minimal(values)[source]

Find the shortest format that can be used to represent all values in an array such that all the string representations are different.

The current implementation is not incredibly efficient, but it takes only ~30ms for a 1000 element array and 200ms for a 10000 element array. One could probably make a more efficient implementation but this is good enough for now for what we use it for.

Returns the optimal format as well as an array of formatted values.