ensure_tuple#

composer.utils.ensure_tuple(x)[source]#

Converts x into a tuple.

  • If x is None, then tuple() is returned.

  • If x is a tuple, then x is returned as-is.

  • If x is a list, then tuple(x) is returned.

  • If x is a dict, then tuple(v for v in x.values()) is returned.

Otherwise, a single element tuple of (x,) is returned.

Parameters

x (Any) โ€“ The input to convert into a tuple.

Returns

tuple โ€“ A tuple of x.