| 287 | @pytest.mark.parametrize("substitute", substitution_values) |
| 288 | @pytest.mark.parametrize("substitution_locations", substitution_locations) |
| 289 | def test_floss_inf_nan(substitute, substitution_locations): |
| 290 | T = np.random.uniform(-1000, 1000, [64]) |
| 291 | m = 5 |
| 292 | n = 30 |
| 293 | data = T.copy() |
| 294 | for substitution_location in substitution_locations: |
| 295 | data[:] = T[:] |
| 296 | data[substitution_location] = substitute |
| 297 | old_data = data[:n] |
| 298 | |
| 299 | mp = naive_right_mp(old_data, m) |
| 300 | comp_mp = stump(old_data, m) |
| 301 | k = mp.shape[0] |
| 302 | |
| 303 | rolling_Ts = core.rolling_window(data[1:], n) |
| 304 | L = 5 |
| 305 | excl_factor = 1 |
| 306 | custom_iac = _iac(k, bidirectional=False) |
| 307 | stream = floss(comp_mp, old_data, m, L, excl_factor, custom_iac=custom_iac) |
| 308 | last_idx = n - m + 1 |
| 309 | excl_zone = int(np.ceil(m / 4)) |
| 310 | zone_start = max(0, k - excl_zone) |
| 311 | for i, ref_T in enumerate(rolling_Ts): |
| 312 | mp[:, 1] = -1 |
| 313 | mp[:, 2] = -1 |
| 314 | mp[:] = np.roll(mp, -1, axis=0) |
| 315 | mp[-1, 0] = np.inf |
| 316 | mp[-1, 3] = last_idx + i |
| 317 | |
| 318 | D = naive.distance_profile(ref_T[-m:], ref_T, m) |
| 319 | D[zone_start:] = np.inf |
| 320 | |
| 321 | ref_T_isfinite = np.isfinite(ref_T) |
| 322 | ref_T_subseq_isfinite = np.all( |
| 323 | core.rolling_window(ref_T_isfinite, m), axis=1 |
| 324 | ) |
| 325 | |
| 326 | D[~ref_T_subseq_isfinite] = np.inf |
| 327 | update_idx = np.argwhere(D < mp[:, 0]).flatten() |
| 328 | mp[update_idx, 0] = D[update_idx] |
| 329 | mp[update_idx, 3] = last_idx + i |
| 330 | |
| 331 | ref_cac_1d = _cac( |
| 332 | mp[:, 3] - i - 1, |
| 333 | L, |
| 334 | bidirectional=False, |
| 335 | excl_factor=excl_factor, |
| 336 | custom_iac=custom_iac, |
| 337 | ) |
| 338 | |
| 339 | ref_mp = mp.copy() |
| 340 | ref_P = ref_mp[:, 0] |
| 341 | ref_I = ref_mp[:, 3] |
| 342 | ref_I[ref_mp[:, 0] == np.inf] = -1 |
| 343 | |
| 344 | stream.update(ref_T[-1]) |
| 345 | comp_cac_1d = stream.cac_1d_ |
| 346 | comp_P = stream.P_ |