()
| 371 | |
| 372 | |
| 373 | def test_naive_match_exclusion_zone(): |
| 374 | # The query appears as a perfect match at location 1 and as very close matches |
| 375 | # (z-normalized distance of 0.05) at location 0, 5 and 9. |
| 376 | # However, since we apply an exclusion zone, the match at index 0 is ignored |
| 377 | T = np.array([0.1, 1.0, 2.0, 3.0, -1.0, 0.1, 1.0, 2.0, -0.5, 0.2, 2.0, 4.0]) |
| 378 | Q = np.array([0.0, 1.0, 2.0]) |
| 379 | m = Q.shape[0] |
| 380 | excl_zone = int(np.ceil(m / 4)) |
| 381 | |
| 382 | left = [ |
| 383 | [0, 1], |
| 384 | [naive.distance(core.z_norm(Q), core.z_norm(T[5 : 5 + m])), 5], |
| 385 | [naive.distance(core.z_norm(Q), core.z_norm(T[9 : 9 + m])), 9], |
| 386 | ] |
| 387 | right = list( |
| 388 | naive_match( |
| 389 | Q, |
| 390 | T, |
| 391 | excl_zone=excl_zone, |
| 392 | max_distance=0.1, |
| 393 | ) |
| 394 | ) |
| 395 | # To avoid sorting errors we first sort based on distance and then based on indices |
| 396 | right.sort(key=lambda x: (x[1], x[0])) |
| 397 | |
| 398 | npt.assert_almost_equal(left, right) |
| 399 | |
| 400 | |
| 401 | @pytest.mark.parametrize("Q, T", test_data) |
nothing calls this directly
no test coverage detected