File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 1111from scipy .spatial import Delaunay
1212from scipy .special import comb
1313from copy import copy
14- import cdd as cdd_float
1514
1615from .material import cached_property
1716
1817from ..utils .math import independent_row_indices
1918
2019
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)
2125try :
26+ cdd_float = importlib .import_module ("cdd" )
2227 cdd_fraction = importlib .import_module ("cdd.gmp" )
2328 cdd_gmp_loaded = True
2429except 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
2736
2837
2938class SimplexGrid (object ):
@@ -140,6 +149,11 @@ def __init__(
140149 dependent endmembers are defined.
141150 :type independent_endmember_occupancies: numpy.array (2D) or None
142151 """
152+ if cdd_float is None :
153+ raise ImportError (
154+ "You need to install pycddlib to create a MaterialPolytope object."
155+ )
156+
143157 if equalities .dtype != inequalities .dtype :
144158 raise Exception (
145159 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