swap_kwargs_dim_to_axis

function of dascore.utils.patch source

swap_kwargs_dim_to_axis(
    patch ,
    kwargs ,
)

Convert dimension names to axis indices in kwargs.

Parameters

Parameter Description
patch : Patch The patch object containing dimension information.
kwargs : dict Keyword arguments potentially containing ‘dim’ parameter.

Returns

dict The kwargs with ‘dim’ converted to ‘axis’ if present.

Examples

import dascore as dc
from dascore.utils.patch import swap_kwargs_dim_to_axis
patch = dc.get_example_patch()
kwargs = {"dim": "time", "dtype": None}
new_kwargs = swap_kwargs_dim_to_axis(patch, kwargs)
# new_kwarg = {'axis': 1, 'dtype': None}