@@ -183,34 +183,22 @@ def _tree_reduce(x, aggregate, axis, keepdims, dtype, split_every=None,
183183 if i in split_every and split_every [i ] != 1 :
184184 depth = int (builtins .max (depth , ceil (log (n , split_every [i ]))))
185185 func = partial (combine or aggregate , axis = axis , keepdims = True )
186- meta_func = None if reduced_meta is None else func
187186 if concatenate :
188187 func = compose (func , partial (_concatenate2 , axes = axis ))
189188 for i in range (depth - 1 ):
190189 x = partial_reduce (func , x , split_every , True , dtype = dtype ,
191190 name = (name or funcname (combine or aggregate )) + '-partial' ,
192- meta_func = meta_func , reduced_meta = reduced_meta )
191+ reduced_meta = reduced_meta )
193192 func = partial (aggregate , axis = axis , keepdims = keepdims )
194- meta_func = None if reduced_meta is None else func
195193 if concatenate :
196194 func = compose (func , partial (_concatenate2 , axes = axis ))
197195 return partial_reduce (func , x , split_every , keepdims = keepdims , dtype = dtype ,
198196 name = (name or funcname (aggregate )) + '-aggregate' ,
199- meta_func = meta_func , reduced_meta = reduced_meta )
200-
201-
202- def try_combinations (func , e , x , combinations ):
203- if len (combinations ) == 1 :
204- return func (x , ** combinations [0 ])
205-
206- try :
207- return func (x , ** combinations [0 ])
208- except e :
209- return try_combinations (func , e , x , combinations [1 :])
197+ reduced_meta = reduced_meta )
210198
211199
212200def partial_reduce (func , x , split_every , keepdims = False , dtype = None , name = None ,
213- meta_func = None , reduced_meta = None ):
201+ reduced_meta = None ):
214202 """ Partial reduction across multiple axes.
215203
216204 Parameters
@@ -250,12 +238,10 @@ def partial_reduce(func, x, split_every, keepdims=False, dtype=None, name=None,
250238 meta = x ._meta
251239 if reduced_meta is not None :
252240 try :
253- # must try multiple argument combinations, some functions may not
254- # support all of them, or even none of them
255- meta = try_combinations (meta_func , TypeError , reduced_meta .compute (),
256- ({'dtype' : dtype , 'keepdims' :True , 'meta' : True },
257- {'meta' :True },
258- {}))
241+ meta = func (reduced_meta .compute (), meta = True )
242+ # no meta keyword argument exists for func, and it isn't required
243+ except TypeError :
244+ meta = func (reduced_meta .compute ())
259245 # when no work can be computed on the empty array (e.g., func is a ufunc)
260246 except ValueError :
261247 pass
0 commit comments