|
| 1 | +"""A tool to pre-compile Numba functions for speeding up DABEST bootstrapping""" |
| 2 | + |
| 3 | +# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/API/precompile.ipynb. |
| 4 | + |
| 5 | +# %% auto 0 |
| 6 | +__all__ = ['precompile_all'] |
| 7 | + |
| 8 | +# %% ../../nbs/API/precompile.ipynb 4 |
| 9 | +import numpy as np |
| 10 | +from tqdm import tqdm |
| 11 | +from . import effsize |
| 12 | +from . import confint_2group_diff |
| 13 | + |
| 14 | +# %% ../../nbs/API/precompile.ipynb 5 |
| 15 | +_NUMBA_COMPILED = False |
| 16 | + |
| 17 | +def precompile_all(): |
| 18 | + """Pre-compile all numba functions with dummy data""" |
| 19 | + global _NUMBA_COMPILED |
| 20 | + |
| 21 | + if _NUMBA_COMPILED: |
| 22 | + return |
| 23 | + |
| 24 | + print("Pre-compiling numba functions for DABEST...") |
| 25 | + |
| 26 | + # Create dummy data |
| 27 | + dummy_control = np.array([1.0, 2.0, 3.0]) |
| 28 | + dummy_test = np.array([4.0, 5.0, 6.0]) |
| 29 | + |
| 30 | + funcs = [ |
| 31 | + # effsize.py functions |
| 32 | + (effsize.cohens_d, (dummy_control, dummy_test)), |
| 33 | + (effsize._mann_whitney_u, (dummy_control, dummy_test)), |
| 34 | + (effsize._cliffs_delta_core, (dummy_control, dummy_test)), |
| 35 | + (effsize._compute_standardizers, (dummy_control, dummy_test)), |
| 36 | + (effsize.weighted_delta, (np.array([1.0, 2.0]), np.array([0.1, 0.2]))), |
| 37 | + |
| 38 | + # confint_2group_diff.py functions |
| 39 | + (confint_2group_diff.create_jackknife_indexes, (dummy_control,)), |
| 40 | + (confint_2group_diff.create_repeated_indexes, (dummy_control,)), |
| 41 | + (confint_2group_diff.bootstrap_indices, (True, 3, 3, 10, 12345)), |
| 42 | + (confint_2group_diff.delta2_bootstrap_loop, |
| 43 | + (dummy_control, dummy_test, dummy_control, dummy_test, 10, 1.0, 12345, False)), |
| 44 | + (confint_2group_diff._compute_quantile, (0.5, 0.1, 0.1)), |
| 45 | + (confint_2group_diff.calculate_group_var, (1.0, 3, 1.0, 3)) |
| 46 | + ] |
| 47 | + |
| 48 | + for func, args in tqdm(funcs, desc="Compiling numba functions"): |
| 49 | + func(*args) |
| 50 | + |
| 51 | + _NUMBA_COMPILED = True |
| 52 | + |
| 53 | + print("Numba compilation complete!") |
0 commit comments