MCPcopy
hub / github.com/dask/dask / arange_safe

Function arange_safe

dask/array/utils.py:427–439  ·  view source on GitHub ↗

Use the `like=` from `np.arange` to create a new array dispatching to the downstream library. If that fails, falls back to the default NumPy behavior, resulting in a `numpy.ndarray`.

(*args, like, **kwargs)

Source from the content-addressed store, hash-verified

425
426
427def arange_safe(*args, like, **kwargs):
428 """
429 Use the `like=` from `np.arange` to create a new array dispatching
430 to the downstream library. If that fails, falls back to the
431 default NumPy behavior, resulting in a `numpy.ndarray`.
432 """
433 if like is None:
434 return np.arange(*args, **kwargs)
435 else:
436 try:
437 return np.arange(*args, like=meta_from_array(like), **kwargs)
438 except TypeError:
439 return np.arange(*args, **kwargs)
440
441
442def _array_like_safe(np_func, da_func, a, like, **kwargs):

Callers 2

arangeFunction · 0.90
takeFunction · 0.90

Calls 2

meta_from_arrayFunction · 0.85
arangeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…