mymesh.utils.SplitRaggedByLength#

mymesh.utils.SplitRaggedByLength(In, return_idx=False, return_inv=False)[source]#

Split a ragged list of lists into a list of array_like groupings of the original list in which all rows are equal length. The returned list will be the length of the number of unique row lengths of the original list of lists.

Parameters:
  • In (list) – List of lists to be sorted

  • return_idx (bool, optional) – Returns the indices of each row of In in the order that they’re sorted into Out, by default False.

Returns:

  • Out (list) – List of array_like groupings of the original list in which all rows are equal length.

  • idx (np.ndarray, optional) – Indices used to reorder In to Out. These are the indices of each row of In in the order that they’re sorted into Out. Returned if return_idx is True.

  • inv (np.ndarray, optional) – Indices to recover the original List (in) from the output (Out). Return if return_inv us True.

Examples

>>> In = [[0,1], [2, 3, 4, 5], [6, 7], [8, 9, 10]]
>>> Out = utils.SplitRaggedByLength(In)
>>> Out