Skip to content

Commit

Permalink
move_quantile(q=0) vs move_min benching
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-riazanov committed Sep 21, 2022
1 parent 42eddad commit c2a2ae3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bottleneck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from .move import move_quantile as move_quantile_c
from .src.move_quantile import move_quantile as move_quantile
from .src.move_quantile import move_min_via_quantile


from .nonreduce import replace
from .nonreduce_axis import (argpartition, nanrankdata, partition, push,
Expand Down
5 changes: 3 additions & 2 deletions bottleneck/benchmark/bench_detailed.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def benchsuite(function, fraction_nan):
setup = """
from bottleneck import %s as bn_fn
try: from numpy import %s as sl_fn
except ImportError: from bottleneck.slow import %s as sl_fn
except ImportError: from bottleneck.slow import move_min as sl_fn
if "%s" != "move_min_via_quantile": from bottleneck.slow import %s as sl_fn
# avoid all-nan slice warnings from np.median and np.nanmedian
if "%s" == "median": from bottleneck.slow import median as sl_fn
Expand Down Expand Up @@ -116,7 +117,7 @@ def benchsuite(function, fraction_nan):
run = {}
run["name"] = [f + signature, array]
run["statements"] = ["bn_fn" + signature, "sl_fn" + signature]
run["setup"] = setup % (f, f, f, f, f, array, fraction_nan, fraction_nan)
run["setup"] = setup % (f, f, f, f, f, f, array, fraction_nan, fraction_nan)
run["repeat"] = repeat
suite.append(run)

Expand Down
8 changes: 7 additions & 1 deletion bottleneck/src/move_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ def move_quantile(*args, **kwargs):
del kwargs['q']
return move_min(*args, **kwargs)

move_quantile.__doc__ = move_quantile_c.__doc__
move_quantile.__doc__ = move_quantile_c.__doc__



def move_min_via_quantile(*args, **kwargs):
kwargs['q'] = 0.
return move_quantile_c(*args, **kwargs)
1 change: 1 addition & 0 deletions bottleneck/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def func_dict():
bn.move_argmax,
bn.move_median,
bn.move_quantile,
bn.move_min_via_quantile,
bn.move_rank,
]
d["nonreduce"] = [bn.replace]
Expand Down

0 comments on commit c2a2ae3

Please sign in to comment.