inline missing class
This commit is contained in:
parent
3fccc2f937
commit
1e7ea4a1c2
1 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue