Skip to content

Commit 8059869

Browse files
authored
Test for IronPython before importing numpy (#1292)
A bare import of numpy in python_optimizers.py would cause failures in IronPython or AEDT. Use the same logic from elsewhere to avoid.
1 parent 1371dcd commit 8059869

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pyaedt/generic/python_optimizers.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import sys
22
import threading
3-
4-
import numpy as np
3+
import warnings
4+
5+
from pyaedt.generic.general_methods import is_ironpython
6+
7+
if not is_ironpython:
8+
try:
9+
import numpy as np
10+
except ImportError:
11+
warnings.warn(
12+
"The NumPy module is required to run some functionalities of PostProcess.\n"
13+
"Install with \n\npip install numpy\n\nRequires CPython."
14+
)
515

616

717
class ThreadTrace(threading.Thread):

0 commit comments

Comments
 (0)