Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_calc_step_size():
assert(scrimp.calc_step_size(4, 0.25) == 1)
m = 4
step_size = 0.25
# test index 0
idx = 0
profile_len = scrimp.calc_profile_len(len(ts), m)
exclusion_zone = scrimp.calc_exclusion_zone(m)
subsequence = scrimp.next_subsequence(ts, idx, m)
X, n, sumx2, sumx, meanx, sigmax2, sigmax = scrimp.fast_find_nn_pre(ts, m)
dp = scrimp.calc_distance_profile(X, subsequence, n, m, meanx, sigmax)
dp = scrimp.apply_exclusion_zone(idx, exclusion_zone, profile_len, dp)
mp = np.zeros(profile_len)
mp_index = np.zeros(profile_len, dtype='int32')
mp, mp_index, idx_nn = scrimp.find_and_store_nn(0, idx, mp, mp_index, dp)
idx_diff = scrimp.calc_idx_diff(idx, idx_nn)
step_size = scrimp.calc_step_size(m, step_size)
beginidx = scrimp.calc_begin_idx(idx, step_size, idx_diff)
refine_distance = np.full(profile_len, np.inf)
result = scrimp.calc_refine_distance_begin_idx(
refine_distance, dp, beginidx, idx, idx_diff, idx_nn, sigmax, meanx, m)
expected_result = np.array([np.inf, np.inf, np.inf, np.inf, np.inf])
np.testing.assert_almost_equal(result, expected_result)
m = 4
step_size = 0.25
# test index 0
idx = 0
profile_len = scrimp.calc_profile_len(len(ts), m)
exclusion_zone = scrimp.calc_exclusion_zone(m)
subsequence = scrimp.next_subsequence(ts, idx, m)
X, n, sumx2, sumx, meanx, sigmax2, sigmax = scrimp.fast_find_nn_pre(ts, m)
dp = scrimp.calc_distance_profile(X, subsequence, n, m, meanx, sigmax)
dp = scrimp.apply_exclusion_zone(idx, exclusion_zone, profile_len, dp)
mp = np.zeros(profile_len)
mp_index = np.zeros(profile_len, dtype='int32')
mp, mp_index, idx_nn = scrimp.find_and_store_nn(0, idx, mp, mp_index, dp)
idx_diff = scrimp.calc_idx_diff(idx, idx_nn)
step_size = scrimp.calc_step_size(m, step_size)
endidx = scrimp.calc_end_idx(profile_len, idx, step_size, idx_diff)
refine_distance = np.full(profile_len, np.inf)
result = scrimp.calc_refine_distance_end_idx(
refine_distance, dp, idx, endidx, meanx, sigmax, idx_nn, idx_diff, m)
expected_result = np.array([np.inf, np.inf, np.inf, np.inf, np.inf])
np.testing.assert_almost_equal(result, expected_result)