inline missing class

This commit is contained in:
Connor Olding 2023-05-04 07:59:54 -07:00
parent 3fccc2f937
commit 1e7ea4a1c2

View File

@ -2,7 +2,22 @@
import numpy as np
from numpy import abs, asarray
from ..common import safe_import
class safe_import:
def __enter__(self):
self.error = False
return self
def __exit__(self, type_, value, traceback):
if type_ is not None:
self.error = True
suppress = not (
os.getenv("SCIPY_ALLOW_BENCH_IMPORT_ERRORS", "1").lower()
in ("0", "false")
or not issubclass(type_, ImportError)
)
return suppress
with safe_import():
from scipy.special import factorial