xarray_einstats.einops.process_pattern_list#
- xarray_einstats.einops.process_pattern_list(redims, handler, allow_dict=True, allow_list=True)[source]#
Process a pattern list and convert it to an einops expression using placeholders.
- Parameters
- redims
list
ofstr
,list
ordict
One of
out_dims
orin_dims
in {func}`~xarray_einstats.einops.rearrange` or {func}`~xarray_einstats.einops.reduce`.- handler
DimHandler
- allow_dict, allow_listbool, optional
Whether or not to allow lists or dicts as elements of
redims
. When processingin_dims
for example we need the names of the variables to be decomposed so dicts are required and lists/tuples are not accepted.
- redims
- Returns
- expression_dims
list
ofstr
A list with the names of the dimensions present in the out expression
- output_dims
list
ofstr
A list with the names of the dimensions present in the output. It differs from
expression_dims
because there might be dimensions being stacked.- pattern
str
The einops expression equivalent to the operations in
redims
pattern list.
- expression_dims
Examples
Whenever we have groupings of dimensions (be it to decompose or to stack),
expression_dims
andoutput_dims
differ:from xarray_einstats.einops import process_pattern_list, DimHandler handler = DimHandler() process_pattern_list(["a", {"b": ("c", "d")}, ("e", "f", "g")], handler)
(['a', 'c', 'd', 'e', 'f', 'g'], ['a', 'b', 'e-f-g'], 'd0 ( d1 d2 ) ( d3 d4 d5 )')