MCPcopy Index your code
hub / github.com/pydata/xarray / either_dict_or_kwargs

Function either_dict_or_kwargs

xarray/namedarray/utils.py:184–200  ·  view source on GitHub ↗
(
    pos_kwargs: Mapping[Any, T] | None,
    kw_kwargs: Mapping[str, T],
    func_name: str,
)

Source from the content-addressed store, hash-verified

182
183
184def either_dict_or_kwargs(
185 pos_kwargs: Mapping[Any, T] | None,
186 kw_kwargs: Mapping[str, T],
187 func_name: str,
188) -> Mapping[Hashable, T]:
189 if pos_kwargs is None or pos_kwargs == {}:
190 # Need an explicit cast to appease mypy due to invariance; see
191 # https://github.com/python/mypy/issues/6228
192 return cast(Mapping[Hashable, T], kw_kwargs)
193
194 if not is_dict_like(pos_kwargs):
195 raise ValueError(f"the first argument to .{func_name} must be a dictionary")
196 if kw_kwargs:
197 raise ValueError(
198 f"cannot specify both keyword and positional arguments to .{func_name}"
199 )
200 return pos_kwargs
201
202
203def _get_chunk( # type: ignore[no-untyped-def]

Callers 15

chunkMethod · 0.90
broadcast_toMethod · 0.90
chunkMethod · 0.90
iselMethod · 0.90
selMethod · 0.90
headMethod · 0.90
tailMethod · 0.90
thinMethod · 0.90
interpMethod · 0.90
_renameMethod · 0.90
rename_dimsMethod · 0.90
rename_varsMethod · 0.90

Calls 1

is_dict_likeFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…