@@ -154,7 +154,7 @@ def _local(self):
154154
155155 def _global (self , glb_idx , decomposition ):
156156 """A "global" view of ``self`` over a given Decomposition."""
157- if self ._is_distributed :
157+ if self ._is_decomposed :
158158 raise ValueError ("Cannot derive a decomposed view from a decomposed Data" )
159159 if len (decomposition ) != self .ndim :
160160 raise ValueError ("`decomposition` should have ndim=%d entries" % self .ndim )
@@ -176,13 +176,12 @@ def _check_idx(func):
176176 @wraps (func )
177177 def wrapper (data , * args , ** kwargs ):
178178 glb_idx = args [0 ]
179- is_gather = isinstance (kwargs .get ('gather_rank' , None ), int )
179+ is_gather = isinstance (kwargs .get ('gather_rank' ), int )
180180 if is_gather and all (i == slice (None , None , 1 ) for i in glb_idx ):
181181 comm_type = gather
182- elif len (args ) > 1 and isinstance (args [1 ], Data ) \
183- and args [1 ]._is_mpi_distributed :
182+ elif len (args ) > 1 and isinstance (args [1 ], Data ) and args [1 ]._is_decomposed :
184183 comm_type = index_by_index
185- elif data ._is_mpi_distributed :
184+ elif data ._is_decomposed :
186185 for i in as_tuple (glb_idx ):
187186 if isinstance (i , slice ) and i .step is not None and i .step < 0 :
188187 comm_type = index_by_index
@@ -196,8 +195,9 @@ def wrapper(data, *args, **kwargs):
196195 return wrapper
197196
198197 @property
199- def _is_mpi_distributed (self ):
200- return self ._is_distributed and configuration ['mpi' ]
198+ def _is_decomposed (self ):
199+ return self ._is_distributed and configuration ['mpi' ] and \
200+ self ._distributor .comm .size > 1
201201
202202 def __repr__ (self ):
203203 return super (Data , self ._local ).__repr__ ()
@@ -341,7 +341,7 @@ def __setitem__(self, glb_idx, val, comm_type):
341341 super ().__setitem__ (loc_idx , val )
342342 else :
343343 super ().__setitem__ (glb_idx , val )
344- elif isinstance (val , Data ) and val ._is_distributed :
344+ elif isinstance (val , Data ) and val ._is_decomposed :
345345 if comm_type is index_by_index :
346346 glb_idx , val = self ._process_args (glb_idx , val )
347347 val_idx = as_tuple ([slice (i .glb_min , i .glb_max + 1 , 1 ) for
@@ -361,14 +361,14 @@ def __setitem__(self, glb_idx, val, comm_type):
361361 or data_global [j ].size == 0
362362 if not skip :
363363 self .__setitem__ (idx_global [j ], data_global [j ])
364- elif self ._is_distributed :
364+ elif self ._is_decomposed :
365365 # `val` is decomposed, `self` is decomposed -> local set
366366 super ().__setitem__ (glb_idx , val )
367367 else :
368368 # `val` is decomposed, `self` is replicated -> gatherall-like
369369 raise NotImplementedError
370370 elif isinstance (val , np .ndarray ):
371- if self ._is_distributed :
371+ if self ._is_decomposed :
372372 # `val` is replicated, `self` is decomposed -> `val` gets decomposed
373373 glb_idx = self ._normalize_index (glb_idx )
374374 glb_idx , val = self ._process_args (glb_idx , val )
@@ -401,7 +401,7 @@ def __setitem__(self, glb_idx, val, comm_type):
401401 pass
402402 super ().__setitem__ (glb_idx , val )
403403 elif isinstance (val , Iterable ):
404- if self ._is_mpi_distributed :
404+ if self ._is_decomposed :
405405 raise NotImplementedError ("With MPI, data can only be set "
406406 "via scalars, numpy arrays or "
407407 "other data " )
@@ -478,7 +478,7 @@ def _index_glb_to_loc(self, glb_idx):
478478 if len (glb_idx ) > self .ndim :
479479 # Maybe user code is trying to add a new axis (see np.newaxis),
480480 # so the resulting array will be higher dimensional than `self`
481- if self ._is_mpi_distributed :
481+ if self ._is_decomposed :
482482 raise ValueError ("Cannot increase dimensionality of MPI-distributed Data" )
483483 else :
484484 # As by specification, we are forced to ignore modulo indexing
@@ -494,7 +494,7 @@ def _index_glb_to_loc(self, glb_idx):
494494 try :
495495 v = convert_index (i , dec , mode = 'glb_to_loc' )
496496 except TypeError :
497- if self ._is_mpi_distributed :
497+ if self ._is_decomposed :
498498 raise NotImplementedError ("Unsupported advanced indexing with "
499499 "MPI-distributed Data" )
500500 v = i
0 commit comments