File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 11
11
from scipy .spatial import Delaunay
12
12
from scipy .special import comb
13
13
from copy import copy
14
- import cdd as cdd_float
15
14
16
15
from .material import cached_property
17
16
18
17
from ..utils .math import independent_row_indices
19
18
20
19
20
+ # Try to import pycddlib.
21
+ # First, try separating the imports into float and
22
+ # fractional, then fall back to only using the float
23
+ # representation, and finally don't import anything
24
+ # (limiting functionality)
21
25
try :
26
+ cdd_float = importlib .import_module ("cdd" )
22
27
cdd_fraction = importlib .import_module ("cdd.gmp" )
23
28
cdd_gmp_loaded = True
24
29
except ImportError :
25
- cdd_fraction = importlib .import_module ("cdd" )
26
- cdd_gmp_loaded = False
30
+ try :
31
+ cdd_float = importlib .import_module ("cdd" )
32
+ cdd_fraction = importlib .import_module ("cdd" )
33
+ cdd_gmp_loaded = False
34
+ except ImportError :
35
+ cdd_float = None
27
36
28
37
29
38
class SimplexGrid (object ):
@@ -140,6 +149,11 @@ def __init__(
140
149
dependent endmembers are defined.
141
150
:type independent_endmember_occupancies: numpy.array (2D) or None
142
151
"""
152
+ if cdd_float is None :
153
+ raise ImportError (
154
+ "You need to install pycddlib to create a MaterialPolytope object."
155
+ )
156
+
143
157
if equalities .dtype != inequalities .dtype :
144
158
raise Exception (
145
159
f"The equalities and inequalities arrays should have the same type ({ equalities .dtype } != { inequalities .dtype } )."
You can’t perform that action at this time.
0 commit comments