Skip to content

Commit d8c074e

Browse files
committed
Fixed #495 Reduce import time
1 parent e4fb1b3 commit d8c074e

File tree

7 files changed

+62
-24
lines changed

7 files changed

+62
-24
lines changed

stumpy/aamp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515

1616
@njit(
17-
"(f8[:], f8[:], i8, b1[:], b1[:], i8[:], i8, i8, i8, f8[:, :, :], i8[:, :, :], b1)",
17+
# "(f8[:], f8[:], i8, b1[:], b1[:], i8[:], i8, i8, i8, f8[:, :, :], i8[:, :, :],"
18+
# "b1)",
1819
fastmath=True,
1920
)
2021
def _compute_diagonal(
@@ -130,7 +131,11 @@ def _compute_diagonal(
130131
return
131132

132133

133-
@njit("(f8[:], f8[:], i8, b1[:], b1[:], i8[:], b1)", parallel=True, fastmath=True)
134+
@njit(
135+
# "(f8[:], f8[:], i8, b1[:], b1[:], i8[:], b1)",
136+
parallel=True,
137+
fastmath=True,
138+
)
134139
def _aamp(T_A, T_B, m, T_A_subseq_isfinite, T_B_subseq_isfinite, diags, ignore_trivial):
135140
"""
136141
A Numba JIT-compiled version of AAMP for parallel computation of the matrix

stumpy/core.py

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,10 @@ def sliding_dot_product(Q, T):
484484
return QT.real[m - 1 : n]
485485

486486

487-
@njit("f8[:](f8[:], i8, b1[:])", fastmath={"nsz", "arcp", "contract", "afn", "reassoc"})
487+
@njit(
488+
# "f8[:](f8[:], i8, b1[:])",
489+
fastmath={"nsz", "arcp", "contract", "afn", "reassoc"}
490+
)
488491
def _welford_nanvar(a, w, a_subseq_isfinite):
489492
"""
490493
Compute the rolling variance for a 1-D array while ignoring NaNs using a modified
@@ -831,7 +834,10 @@ def compute_mean_std(T, m):
831834
)
832835

833836

834-
@njit("f8(i8, f8, f8, f8, f8, f8)", fastmath=True)
837+
@njit(
838+
# "f8(i8, f8, f8, f8, f8, f8)",
839+
fastmath=True
840+
)
835841
def _calculate_squared_distance(m, QT, μ_Q, σ_Q, M_T, Σ_T):
836842
"""
837843
Compute a single squared distance given all scalar inputs. This function serves as
@@ -889,7 +895,11 @@ def _calculate_squared_distance(m, QT, μ_Q, σ_Q, M_T, Σ_T):
889895
return D_squared
890896

891897

892-
@njit("f8[:](i8, f8[:], f8, f8, f8[:], f8[:])", parallel=True, fastmath=True)
898+
@njit(
899+
# "f8[:](i8, f8[:], f8, f8, f8[:], f8[:])",
900+
parallel=True,
901+
fastmath=True,
902+
)
893903
def _calculate_squared_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T):
894904
"""
895905
Compute the squared distance profile
@@ -935,7 +945,11 @@ def _calculate_squared_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T):
935945
return D_squared
936946

937947

938-
@njit("f8[:](i8, f8[:], f8, f8, f8[:], f8[:])", parallel=True, fastmath=True)
948+
@njit(
949+
# "f8[:](i8, f8[:], f8, f8, f8[:], f8[:])",
950+
parallel=True,
951+
fastmath=True,
952+
)
939953
def calculate_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T):
940954
"""
941955
Compute the distance profile
@@ -977,7 +991,10 @@ def calculate_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T):
977991
return np.sqrt(D_squared)
978992

979993

980-
@njit("f8[:](f8, f8[:], f8[:])", fastmath=True)
994+
@njit(
995+
# "f8[:](f8, f8[:], f8[:])",
996+
fastmath=True
997+
)
981998
def _mass_absolute(Q_squared, T_squared, QT):
982999
"""
9831000
A Numba JIT compiled algorithm for computing the non-normalized distance profile
@@ -1182,7 +1199,10 @@ def mueen_calculate_distance_profile(Q, T):
11821199
return np.sqrt(D)
11831200

11841201

1185-
@njit("f8[:](f8[:], f8[:], f8[:], f8, f8, f8[:], f8[:])", fastmath=True)
1202+
@njit(
1203+
# "f8[:](f8[:], f8[:], f8[:], f8, f8, f8[:], f8[:])",
1204+
fastmath=True
1205+
)
11861206
def _mass(Q, T, QT, μ_Q, σ_Q, M_T, Σ_T):
11871207
"""
11881208
A Numba JIT compiled algorithm for computing the distance profile using the MASS
@@ -1401,7 +1421,10 @@ def _get_QT(start, T_A, T_B, m):
14011421
return QT, QT_first
14021422

14031423

1404-
@njit(["(f8[:], i8, i8)", "(f8[:, :], i8, i8)"], fastmath=True)
1424+
@njit(
1425+
# ["(f8[:], i8, i8)", "(f8[:, :], i8, i8)"],
1426+
fastmath=True
1427+
)
14051428
def apply_exclusion_zone(D, idx, excl_zone):
14061429
"""
14071430
Apply an exclusion zone to an array (inplace), i.e. set all values
@@ -1606,7 +1629,11 @@ def array_to_temp_file(a):
16061629
return fname
16071630

16081631

1609-
@njit("i8[:](i8[:], i8, i8, i8)", parallel=True, fastmath=True)
1632+
@njit(
1633+
# "i8[:](i8[:], i8, i8, i8)",
1634+
parallel=True,
1635+
fastmath=True,
1636+
)
16101637
def _count_diagonal_ndist(diags, m, n_A, n_B):
16111638
"""
16121639
Count the number of distances that would be computed for each diagonal index
@@ -1642,7 +1669,9 @@ def _count_diagonal_ndist(diags, m, n_A, n_B):
16421669
return diag_ndist_counts
16431670

16441671

1645-
@njit("i8[:, :](i8[:], i8, b1)")
1672+
@njit(
1673+
# "i8[:, :](i8[:], i8, b1)"
1674+
)
16461675
def _get_array_ranges(a, n_chunks, truncate):
16471676
"""
16481677
Given an input array, split it into `n_chunks`.

stumpy/maamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ def _get_first_maamp_profile(
326326

327327

328328
@njit(
329-
"(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, b1[:, :], b1[:, :], f8[:, :], f8[:, :],"
330-
"f8[:, :], f8[:, :], f8[:, :])",
329+
# "(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, b1[:, :], b1[:, :], f8[:, :],"
330+
# "f8[:, :], f8[:, :], f8[:, :], f8[:, :])",
331331
parallel=True,
332332
fastmath=True,
333333
)

stumpy/mstump.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ def _get_multi_QT(start, T, m):
612612

613613

614614
@njit(
615-
"(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, f8[:, :], f8[:, :], f8[:, :], f8[:, :],"
616-
"f8[:, :], f8[:, :], f8[:, :])",
615+
# "(i8, i8, i8, f8[:, :], f8[:, :], i8, i8, f8[:, :], f8[:, :], f8[:, :],"
616+
# "f8[:, :], f8[:, :], f8[:, :], f8[:, :])",
617617
parallel=True,
618618
fastmath=True,
619619
)
@@ -714,7 +714,11 @@ def _compute_multi_D(
714714
core.apply_exclusion_zone(D, idx, excl_zone)
715715

716716

717-
@njit("(i8, i8, f8[:, :], f8[:], i8, f8[:, :], i8[:, :])", parallel=True, fastmath=True)
717+
@njit(
718+
# "(i8, i8, f8[:, :], f8[:], i8, f8[:, :], i8[:, :])",
719+
parallel=True,
720+
fastmath=True,
721+
)
718722
def _compute_PI(d, idx, D, D_prime, range_start, P, I):
719723
"""
720724
A Numba JIT-compiled version of mSTOMP for updating the matrix profile and matrix

stumpy/scraamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616

1717
@njit(
18-
"(f8[:], f8[:], i8, b1[:], b1[:], f8[:], f8[:], f8[:], i8, i8, f8[:], f8[:], i8[:],"
19-
"optional(i8))",
18+
# "(f8[:], f8[:], i8, b1[:], b1[:], f8[:], f8[:], f8[:], i8, i8, f8[:], f8[:],"
19+
# "i8[:], optional(i8))",
2020
parallel=True,
2121
fastmath=True,
2222
)

stumpy/scrump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616

1717
@njit(
18-
"(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], i8, i8, f8[:], f8[:], i8[:],"
19-
"optional(i8))",
18+
# "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], i8, i8, f8[:], f8[:],"
19+
# "i8[:], optional(i8))",
2020
parallel=True,
2121
fastmath=True,
2222
)

stumpy/stump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616

1717
@njit(
18-
"(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], b1[:],"
19-
"b1[:], b1[:], b1[:], i8[:], i8, i8, i8, f8[:, :, :], i8[:, :, :], b1)",
18+
# "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], f8[:],"
19+
# "b1[:], b1[:], b1[:], b1[:], i8[:], i8, i8, i8, f8[:, :, :], i8[:, :, :], b1)",
2020
fastmath=True,
2121
)
2222
def _compute_diagonal(
@@ -214,8 +214,8 @@ def _compute_diagonal(
214214

215215

216216
@njit(
217-
"(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], b1[:], b1[:], b1[:],"
218-
"b1[:], i8[:], b1)",
217+
# "(f8[:], f8[:], i8, f8[:], f8[:], f8[:], f8[:], f8[:], f8[:], b1[:], b1[:],"
218+
# "b1[:], b1[:], i8[:], b1)",
219219
parallel=True,
220220
fastmath=True,
221221
)

0 commit comments

Comments
 (0)