hpcflow.sdk.core.utils.flatten#

hpcflow.sdk.core.utils.flatten(lst)#

Flatten an arbitrarily (but of uniform depth) nested list and return shape information to enable un-flattening.

Un-flattening can be performed with the reshape() function.

lst

List to be flattened. Each element must contain all lists or otherwise all items that are considered to be at the “bottom” of the nested structure (e.g. integers). For example, [[1, 2], [3]] is permitted and flattens to [1, 2, 3], but [[1, 2], 3] is not permitted because the first element is a list, but the second is not.