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

Function _wrapped_numpy_funcname

dask/dataframe/dask_expr/_collection.py:312–334  ·  view source on GitHub ↗

Return the name of the public NumPy function that called ``__array_wrap__``, or None if the caller is not NumPy. Depending on the NumPy version, private helpers (``_wrapfunc``, ``_wrapit``) may sit between the public function and ``__array_wrap__``; skip them.

()

Source from the content-addressed store, hash-verified

310
311
312def _wrapped_numpy_funcname() -> str | None:
313 """Return the name of the public NumPy function that called ``__array_wrap__``,
314 or None if the caller is not NumPy.
315
316 Depending on the NumPy version, private helpers (``_wrapfunc``, ``_wrapit``)
317 may sit between the public function and ``__array_wrap__``; skip them.
318 """
319 # Caller of __array_wrap__
320 try:
321 frame = sys._getframe(1)
322 except AttributeError: # Not CPython
323 frame = inspect.stack()[1].frame # pragma: nocover
324 assert frame.f_back is not None
325 frame = frame.f_back
326
327 while frame.f_globals.get("__name__", "").startswith("numpy."):
328 name = frame.f_code.co_name
329 if not name.startswith("_"):
330 return name
331 if frame.f_back is None:
332 return None
333 frame = frame.f_back
334 return None
335
336
337class FrameBase(DaskMethodsMixin):

Callers 2

__array_wrap__Method · 0.85
__array_wrap__Method · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected