translate_pattern#

xarray_einstats.einops.translate_pattern(pattern)[source]#

Translate a string pattern to a list pattern.

Parameters:
patternstr

Input pattern as a string. The raw_ wrappers use these patterns.

Returns:
list of str, list or dict

Pattern translated to list, as used by the full fledged wrappers instead of the raw_ ones.

Examples

from xarray_einstats.einops import translate_pattern
translate_pattern("a (c d)=b (e f g)")
['a', {'b': ['c', 'd']}, ['e', 'f', 'g']]