Skip to content

Commit 3d294d1

Browse files
committed
remove explicit exceptions from _is_torch_array and _is_jax_array
1 parent ec68363 commit 3d294d1

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

lib/matplotlib/cbook.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import time
2020
import traceback
2121
import types
22-
import warnings
2322
import weakref
2423

2524
import numpy as np
@@ -2238,22 +2237,14 @@ def _picklable_class_constructor(mixin_class, fmt, attr_name, base_class):
22382237
def _is_torch_array(x):
22392238
try:
22402239
return isinstance(x, sys.modules['torch'].Tensor)
2241-
except (KeyError, AttributeError, TypeError):
2242-
return False
2243-
except Exception as e:
2244-
warnings.warn(f"Error checking if {x} is a PyTorch Tensor: \n {e} \
2245-
\n Please report this issue to the developers.")
2240+
except Exception as e: # not using bare `except` to bypass flake8
22462241
return False
22472242

22482243

22492244
def _is_jax_array(x):
22502245
try:
22512246
return isinstance(x, sys.modules['jax'].Array)
2252-
except (KeyError, AttributeError, TypeError):
2253-
return False
2254-
except Exception as e:
2255-
warnings.warn(f"Error checking if {x} is a JAX Array: \n {e} \
2256-
\n Please report this issue to the developers.")
2247+
except Exception as e: # not using bare `except` to bypass flake8
22572248
return False
22582249

22592250

0 commit comments

Comments
 (0)