MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _is_torch_array

Function _is_torch_array

lib/matplotlib/cbook.py:2430–2439  ·  view source on GitHub ↗

Return whether *x* is a PyTorch Tensor.

(x)

Source from the content-addressed store, hash-verified

2428
2429
2430def _is_torch_array(x):
2431 """Return whether *x* is a PyTorch Tensor."""
2432 try:
2433 # We're intentionally not attempting to import torch. If somebody
2434 # has created a torch array, torch should already be in sys.modules.
2435 tp = sys.modules.get("torch").Tensor
2436 except AttributeError:
2437 return False # Module not imported or a nonstandard module with no Tensor attr.
2438 return (isinstance(tp, type) # Just in case it's a very nonstandard module.
2439 and isinstance(x, tp))
2440
2441
2442def _is_jax_array(x):

Callers 1

_unpack_to_numpyFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…