waltlabtools.core.flatten

flatten(data, on_bad_data='warn')[source]

Flattens most data structures.

Parameters
  • data (any) -- The data structure to be flattened. Can also be a primitive.

  • on_bad_data ({"error", "ignore", "warn"}, default "warn") -- Specifies what to do when the data cannot be coerced to an ndarray. Options are as follows:

    • "error" : Raises TypeError.

    • "ignore" : Returns a list or, failing that, the original object.

    • "warn" : Returns as in "ignore", but raises a warning.

Returns

flattened_data (array, list, or primitive) -- Flattened version of data. If on_bad_data="error", always an array.