pdstools.utils.cdh_utils._misc

Miscellaneous helpers that don’t belong to a single concern.

Functions

safe_flatten_list(→ list | None)

Flatten one level of alist, drop None entries, and prepend extras.

legend_color_order(fig)

Orders legend colors alphabetically in order to provide pega color

Module Contents

safe_flatten_list(alist: list | None, extras: list | None = None) list | None

Flatten one level of alist, drop None entries, and prepend extras.

The result is order-preserving and de-duplicated. Strings are treated as atoms (not iterated). Both alist and extras are read-only — the caller’s lists are never mutated. Returns None when the result would be empty so callers can use the truthiness as a “no grouping” signal.

Parameters:
  • alist (list | None)

  • extras (list | None)

Return type:

list | None

legend_color_order(fig)

Orders legend colors alphabetically in order to provide pega color consistency among different categories