Skip to content

Commit

Permalink
replaced hardcoded fastmath value with config var
Browse files Browse the repository at this point in the history
  • Loading branch information
NimaSarajpoor committed Dec 26, 2024
1 parent f17f92d commit e543379
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions stumpy/aamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions stumpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion stumpy/maamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion stumpy/mstump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions stumpy/scraamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions stumpy/scrump.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _preprocess_prescrump(
)


@njit(fastmath=True)
@njit(fastmath=config.STUMPY_FASTMATH)
def _compute_PI(
T_A,
T_B,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions stumpy/stump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e543379

Please sign in to comment.