@@ -3943,42 +3943,29 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
3943
3943
if np .issubdtype (a .dtype , np .inexact ):
3944
3944
indices_above = concatenate ((indices_above , [- 1 ]))
3945
3945
3946
- weights_above = indices - indices_below
3947
- weights_below = 1 - weights_above
3948
-
3949
- weights_shape = [1 , ] * ap .ndim
3950
- weights_shape [axis ] = len (indices )
3951
- weights_below .shape = weights_shape
3952
- weights_above .shape = weights_shape
3953
-
3954
3946
ap .partition (concatenate ((indices_below , indices_above )), axis = axis )
3955
3947
3956
3948
# ensure axis with q-th is first
3957
3949
ap = np .moveaxis (ap , axis , 0 )
3958
- weights_below = np .moveaxis (weights_below , axis , 0 )
3959
- weights_above = np .moveaxis (weights_above , axis , 0 )
3960
3950
axis = 0
3961
3951
3952
+ weights_shape = [1 ] * ap .ndim
3953
+ weights_shape [axis ] = len (indices )
3954
+ weights_above = (indices - indices_below ).reshape (weights_shape )
3955
+
3962
3956
# Check if the array contains any nan's
3963
3957
if np .issubdtype (a .dtype , np .inexact ):
3964
3958
indices_above = indices_above [:- 1 ]
3965
3959
n = np .isnan (ap [- 1 :, ...])
3966
3960
3967
- x1 = take (ap , indices_below , axis = axis ) * weights_below
3961
+ x1 = take (ap , indices_below , axis = axis ) * ( 1 - weights_above )
3968
3962
x2 = take (ap , indices_above , axis = axis ) * weights_above
3969
3963
3970
- # ensure axis with q-th is first
3971
- x1 = np .moveaxis (x1 , axis , 0 )
3972
- x2 = np .moveaxis (x2 , axis , 0 )
3973
-
3974
3964
if zerod :
3975
3965
x1 = x1 .squeeze (0 )
3976
3966
x2 = x2 .squeeze (0 )
3977
3967
3978
- if out is not None :
3979
- r = add (x1 , x2 , out = out )
3980
- else :
3981
- r = add (x1 , x2 )
3968
+ r = add (x1 , x2 , out = out )
3982
3969
3983
3970
if np .any (n ):
3984
3971
if zerod :
0 commit comments