diff --git a/benchmark/benchmarks/pairwise_loop.py b/benchmark/benchmarks/pairwise_loop.py new file mode 100644 index 000000000..8f3fee434 --- /dev/null +++ b/benchmark/benchmarks/pairwise_loop.py @@ -0,0 +1,18 @@ +#from: http://jakevdp.github.com/blog/2012/08/24/numba-vs-cython/ +#setup: import numpy as np ; X = np.linspace(0,10,200).reshape(20,10) +#run: pairwise_loop(X) + +#pythran export pairwise_loop(float [][]) + +import numpy as np +def pairwise_loop(X): + M, N = X.shape + D = np.empty((M,M)) + for i in range(M): + for j in range(M): + d = 0.0 + for k in range(N): + tmp = X[i,k] - X[j,k] + d += tmp * tmp + D[i,j] = np.sqrt(d) + return D diff --git a/test/conftest.py b/test/conftest.py index 877b501f2..81154ae62 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -55,11 +55,14 @@ def _display_driver_logs(browser, driver): class SeleniumWrapper: - def __init__(self, build_dir, server_port, server_hostname='127.0.0.1', - server_log=None): + def __init__(self, server_port, server_hostname='127.0.0.1', + server_log=None, build_dir=None): from selenium.webdriver.support.wait import WebDriverWait from selenium.common.exceptions import TimeoutException + if build_dir is None: + build_dir = BUILD_PATH + driver = self.get_driver() wait = WebDriverWait(driver, timeout=20) if not (pathlib.Path(build_dir) / 'test.html').exists(): @@ -223,7 +226,10 @@ def web_server_secondary(request): @contextlib.contextmanager -def spawn_web_server(build_dir): +def spawn_web_server(build_dir=None): + + if build_dir is None: + build_dir = BUILD_PATH tmp_dir = tempfile.mkdtemp() log_path = pathlib.Path(tmp_dir) / 'http-server.log' @@ -312,7 +318,7 @@ def run_web_server(q, log_filepath, build_dir): if (__name__ == '__main__' and multiprocessing.current_process().name == 'MainProcess' and not hasattr(sys, "_pytest_session")): - with spawn_web_server(BUILD_PATH): + with spawn_web_server(): # run forever while True: time.sleep(1)