8383import scipy .sparse as sp
8484
8585from discretize import utils
86-
87- try :
88- from . import TreeUtils
89- _IMPORT_TREEUTILS = True
90- except Exception :
91- _IMPORT_TREEUTILS = False
92-
86+ from . import TreeUtils
9387
9488from .InnerProducts import InnerProducts
9589from .TensorMesh import TensorMesh , BaseTensorMesh
@@ -105,13 +99,8 @@ class TreeMesh(BaseTensorMesh, InnerProducts, TreeMeshIO):
10599 _meshType = 'TREE'
106100
107101 def __init__ (self , h , x0 = None , levels = None ):
108- if not _IMPORT_TREEUTILS :
109- raise Exception (
110- 'Could not import the Cython code to run the '
111- 'TreeMesh Try:.\n \n python setup.py build_ext --inplace'
112- )
113102 assert type (h ) is list , 'h must be a list'
114- assert len (h ) in [2 , 3 ], "There is only support for TreeMesh in 2D or 3D."
103+ assert len (h ) in [2 , 3 ], "TreeMesh is only in 2D or 3D."
115104
116105 BaseTensorMesh .__init__ (self , h , x0 )
117106
@@ -370,7 +359,8 @@ def ntEx(self):
370359
371360 @property
372361 def ntEy (self ):
373- if self .dim == 2 :return self .ntFx
362+ if self .dim == 2 :
363+ return self .ntFx
374364 self .number ()
375365 return len (self ._edgesY )
376366
@@ -389,13 +379,13 @@ def _sortedCells(self):
389379
390380 @property
391381 def permuteCC (self ):
392- #TODO: cache these?
382+ # TODO: cache these?
393383 P = SortGrid (self .gridCC )
394384 return sp .identity (self .nC ).tocsr ()[P ,:]
395385
396386 @property
397387 def permuteF (self ):
398- #TODO: cache these?
388+ # TODO: cache these?
399389 P = SortGrid (self .gridFx )
400390 P += SortGrid (self .gridFy , offset = self .nFx )
401391 if self .dim == 3 :
@@ -404,16 +394,16 @@ def permuteF(self):
404394
405395 @property
406396 def permuteE (self ):
407- #TODO: cache these?
397+ # TODO: cache these?
408398 if self .dim == 2 :
409399 P = SortGrid (self .gridFy )
410400 P += SortGrid (self .gridFx , offset = self .nEx )
411- return sp .identity (self .nE ).tocsr ()[P ,:]
401+ return sp .identity (self .nE ).tocsr ()[P , :]
412402 if self .dim == 3 :
413403 P = SortGrid (self .gridEx )
414404 P += SortGrid (self .gridEy , offset = self .nEx )
415405 P += SortGrid (self .gridEz , offset = self .nEx + self .nEy )
416- return sp .identity (self .nE ).tocsr ()[P ,:]
406+ return sp .identity (self .nE ).tocsr ()[P , :]
417407
418408 def _index (self , pointer ):
419409 assert len (pointer ) is self .dim + 1
0 commit comments