@@ -98,7 +98,8 @@ def __shape_setup__(cls, **kwargs):
9898 shape = kwargs .get ('shape' , kwargs .get ('shape_global' ))
9999 dimensions = kwargs .get ('dimensions' )
100100 npoint = kwargs .get ('npoint' , kwargs .get ('npoint_global' ))
101- glb_npoint = SparseDistributor .decompose (npoint , grid .distributor )
101+ distributor = kwargs .get ('distributor' , SparseDistributor )
102+ glb_npoint = distributor .decompose (npoint , grid .distributor )
102103 # Plain SparseFunction construction with npoint.
103104 if shape is None :
104105 loc_shape = (glb_npoint [grid .distributor .myrank ],)
@@ -146,7 +147,7 @@ def __subfunc_setup__(self, suffix, keys, dtype=None, inkwargs=False, **kwargs):
146147 for k in keys :
147148 if k not in kwargs :
148149 continue
149- elif kwargs [k ] is None :
150+ elif kwargs [k ] is None and inkwargs :
150151 # In cases such as rebuild,
151152 # the subfunction may be passed explicitly as None
152153 return None
@@ -214,7 +215,6 @@ def __subfunc_setup__(self, suffix, keys, dtype=None, inkwargs=False, **kwargs):
214215 # Complex coordinates are not valid, so fall back to corresponding
215216 # real floating point type if dtype is complex.
216217 dtype = dtype (0 ).real .__class__
217-
218218 sf = SparseSubFunction (
219219 name = name , dtype = dtype , dimensions = dimensions ,
220220 shape = shape , space_order = 0 , initializer = key , alias = self .alias ,
0 commit comments