MCPcopy Create free account
hub / github.com/dask/dask / arange_safe

Function arange_safe

dask/array/utils.py:429–441  ·  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

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