From e543379ae901a904c99fa49955c9276c8ac0748c Mon Sep 17 00:00:00 2001 From: NimaSarajpoor Date: Wed, 25 Dec 2024 22:58:50 -0500 Subject: [PATCH] replaced hardcoded fastmath value with config var --- stumpy/aamp.py | 4 ++-- stumpy/core.py | 24 ++++++++++++------------ stumpy/maamp.py | 2 +- stumpy/mstump.py | 2 +- stumpy/scraamp.py | 4 ++-- stumpy/scrump.py | 4 ++-- stumpy/stump.py | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/stumpy/aamp.py b/stumpy/aamp.py index edc2da7af..02504ec0f 100644 --- a/stumpy/aamp.py +++ b/stumpy/aamp.py @@ -13,7 +13,7 @@ @njit( # "(f8[:], f8[:], i8, b1[:], b1[:], f8, i8[:], i8, i8, i8, f8[:, :, :]," # "f8[:, :], f8[:, :], i8[:, :, :], i8[:, :], i8[:, :], b1)", - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _compute_diagonal( T_A, @@ -186,7 +186,7 @@ def _compute_diagonal( @njit( # "(f8[:], f8[:], i8, b1[:], b1[:], i8[:], b1, i8)", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _aamp( T_A, diff --git a/stumpy/core.py b/stumpy/core.py index b748187b9..a2801410d 100644 --- a/stumpy/core.py +++ b/stumpy/core.py @@ -589,7 +589,7 @@ def check_window_size(m, max_size=None): raise ValueError(f"The window size must be less than or equal to {max_size}") -@njit(fastmath=True) +@njit(fastmath=config.STUMPY_FASTMATH) def _sliding_dot_product(Q, T): """ A Numba JIT-compiled implementation of the sliding window dot product. @@ -657,7 +657,7 @@ def sliding_dot_product(Q, T): @njit( # "f8[:](f8[:], i8, b1[:])", - fastmath={"nsz", "arcp", "contract", "afn", "reassoc"} + fastmath=config.STUMPY_FASTMATH_FLAGS ) def _welford_nanvar(a, w, a_subseq_isfinite): """ @@ -771,7 +771,7 @@ def welford_nanstd(a, w=None): return np.sqrt(np.clip(welford_nanvar(a, w), a_min=0, a_max=None)) -@njit(parallel=True, fastmath={"nsz", "arcp", "contract", "afn", "reassoc"}) +@njit(parallel=True, fastmath=config.STUMPY_FASTMATH_FLAGS) def _rolling_nanstd_1d(a, w): """ A Numba JIT-compiled and parallelized function for computing the rolling standard @@ -1110,7 +1110,7 @@ def _calculate_squared_distance( @njit( # "f8[:](i8, f8[:], f8, f8, f8[:], f8[:])", - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _calculate_squared_distance_profile( m, QT, μ_Q, σ_Q, M_T, Σ_T, Q_subseq_isconstant, T_subseq_isconstant @@ -1176,7 +1176,7 @@ def _calculate_squared_distance_profile( @njit( # "f8[:](i8, f8[:], f8, f8, f8[:], f8[:])", - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def calculate_distance_profile( m, QT, μ_Q, σ_Q, M_T, Σ_T, Q_subseq_isconstant, T_subseq_isconstant @@ -1229,7 +1229,7 @@ def calculate_distance_profile( return np.sqrt(D_squared) -@njit(fastmath=True) +@njit(fastmath=config.STUMPY_FASTMATH) def _p_norm_distance_profile(Q, T, p=2.0): """ A Numba JIT-compiled and parallelized function for computing the p-normalized @@ -1505,7 +1505,7 @@ def mueen_calculate_distance_profile(Q, T): @njit( # "f8[:](f8[:], f8[:], f8[:], f8, f8, f8[:], f8[:])", - fastmath=True + fastmath=config.STUMPY_FASTMATH ) def _mass(Q, T, QT, μ_Q, σ_Q, M_T, Σ_T, Q_subseq_isconstant, T_subseq_isconstant): """ @@ -1978,7 +1978,7 @@ def _get_QT(start, T_A, T_B, m): @njit( # ["(f8[:], i8, i8)", "(f8[:, :], i8, i8)"], - fastmath=True + fastmath=config.STUMPY_FASTMATH ) def _apply_exclusion_zone(a, idx, excl_zone, val): """ @@ -2308,7 +2308,7 @@ def array_to_temp_file(a): @njit( # "i8[:](i8[:], i8, i8, i8)", - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _count_diagonal_ndist(diags, m, n_A, n_B): """ @@ -2505,7 +2505,7 @@ def rolling_isfinite(a, w): ) -@njit(parallel=True, fastmath={"nsz", "arcp", "contract", "afn", "reassoc"}) +@njit(parallel=True, fastmath=config.STUMPY_FASTMATH_FLAGS) def _rolling_isconstant(a, w): """ Compute the rolling isconstant for 1-D array. @@ -2842,7 +2842,7 @@ def _idx_to_mp( return P -@njit(fastmath=True) +@njit(fastmath=config.STUMPY_FASTMATH) def _total_diagonal_ndists(tile_lower_diag, tile_upper_diag, tile_height, tile_width): """ Count the total number of distances covered by a range of diagonals @@ -3970,7 +3970,7 @@ def _mdl(disc_subseqs, disc_neighbors, S, n_bit=8): @njit( # "(i8, i8, f8[:, :], f8[:], i8, f8[:, :], i8[:, :], f8)", - fastmath={"nsz", "arcp", "contract", "afn", "reassoc"}, + fastmath=config.STUMPY_FASTMATH_FLAGS, ) def _compute_multi_PI(d, idx, D, D_prime, range_start, P, I, p=2.0): """ diff --git a/stumpy/maamp.py b/stumpy/maamp.py index d142c8e40..35fe5fdb8 100644 --- a/stumpy/maamp.py +++ b/stumpy/maamp.py @@ -592,7 +592,7 @@ def _get_multi_p_norm(start, T, m, p=2.0): # "(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, b1[:, :], b1[:, :], f8," # "f8[:, :], f8[:, :], f8[:, :])", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _compute_multi_p_norm( d, diff --git a/stumpy/mstump.py b/stumpy/mstump.py index 9b2dab7d4..44950106e 100644 --- a/stumpy/mstump.py +++ b/stumpy/mstump.py @@ -811,7 +811,7 @@ def _get_multi_QT(start, T, m): # "(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, f8[:, :], f8[:, :], f8[:, :]," # "f8[:, :], f8[:, :], f8[:, :], f8[:, :])", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _compute_multi_D( d, diff --git a/stumpy/scraamp.py b/stumpy/scraamp.py index 5c62606e3..c85c7fa6d 100644 --- a/stumpy/scraamp.py +++ b/stumpy/scraamp.py @@ -83,7 +83,7 @@ def _preprocess_prescraamp(T_A, m, T_B=None, s=None): return (T_A, T_B, T_A_subseq_isfinite, T_B_subseq_isfinite, indices, s, excl_zone) -@njit(fastmath=True) +@njit(fastmath=config.STUMPY_FASTMATH) def _compute_PI( T_A, T_B, @@ -286,7 +286,7 @@ def _compute_PI( # "(f8[:], f8[:], i8, b1[:], b1[:], f8, i8, i8, f8[:], f8[:]," # "i8[:], optional(i8))", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _prescraamp( T_A, diff --git a/stumpy/scrump.py b/stumpy/scrump.py index 7367a8885..601fc9d8e 100644 --- a/stumpy/scrump.py +++ b/stumpy/scrump.py @@ -133,7 +133,7 @@ def _preprocess_prescrump( ) -@njit(fastmath=True) +@njit(fastmath=config.STUMPY_FASTMATH) def _compute_PI( T_A, T_B, @@ -384,7 +384,7 @@ def _compute_PI( # "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], i8, i8, f8[:], f8[:]," # "i8[:], optional(i8))", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _prescrump( T_A, diff --git a/stumpy/stump.py b/stumpy/stump.py index 6c3a10721..dc435c2e4 100644 --- a/stumpy/stump.py +++ b/stumpy/stump.py @@ -15,7 +15,7 @@ # "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:]," # "b1[:], b1[:], b1[:], b1[:], i8[:], i8, i8, i8, f8[:, :, :], f8[:, :]," # "f8[:, :], i8[:, :, :], i8[:, :], i8[:, :], b1)", - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _compute_diagonal( T_A, @@ -247,7 +247,7 @@ def _compute_diagonal( # "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], b1[:], b1[:]," # "b1[:], b1[:], i8[:], b1, i8)", parallel=True, - fastmath=True, + fastmath=config.STUMPY_FASTMATH, ) def _stump( T_A,