MCPcopy Index your code
hub / github.com/stumpy-dev/stumpy / test_multi_mass_with_isconstant

Function test_multi_mass_with_isconstant

tests/test_mstump.py:411–490  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

409
410
411def test_multi_mass_with_isconstant():
412 d = 3
413 n = 64
414 m = 8
415
416 # case 1: Q is not multi-subseq of T
417 T = np.random.uniform(-1000, 1000, size=[d, n])
418 T_subseq_isconstant = np.random.choice(
419 [True, False], size=(d, n - m + 1), replace=True
420 )
421
422 Q = np.random.uniform(-1000, 1000, size=[d, m])
423 Q_subseq_isconstant = np.random.choice([True, False], size=(d, 1), replace=True)
424
425 ref = naive.multi_mass(
426 Q,
427 T,
428 m,
429 T_subseq_isconstant=T_subseq_isconstant,
430 Q_subseq_isconstant=Q_subseq_isconstant,
431 )
432
433 T_subseq_isconstant = core.rolling_isconstant(T, m, T_subseq_isconstant)
434 M_T, Σ_T = core.compute_mean_std(T, m)
435
436 Q_subseq_isconstant = core.rolling_isconstant(Q, m, Q_subseq_isconstant)
437 μ_Q, σ_Q = core.compute_mean_std(Q, m)
438
439 comp = _multi_mass(
440 Q,
441 T,
442 m,
443 M_T,
444 Σ_T,
445 μ_Q,
446 σ_Q,
447 T_subseq_isconstant=T_subseq_isconstant,
448 Q_subseq_isconstant=Q_subseq_isconstant,
449 )
450
451 npt.assert_almost_equal(ref, comp, decimal=config.STUMPY_TEST_PRECISION)
452
453 # case 2: Q is a multi-subseq of T
454 T = np.random.uniform(-1000, 1000, size=[d, n])
455 T_subseq_isconstant = np.random.choice(
456 [True, False], size=(d, n - m + 1), replace=True
457 )
458
459 query_idx = np.random.randint(0, n - m + 1)
460 Q = T[:, query_idx : query_idx + m]
461 Q_subseq_isconstant = np.expand_dims(T_subseq_isconstant[:, query_idx], 1)
462
463 ref = naive.multi_mass(
464 Q,
465 T,
466 m,
467 T_subseq_isconstant=T_subseq_isconstant,
468 Q_subseq_isconstant=Q_subseq_isconstant,

Callers

nothing calls this directly

Calls 1

_multi_massFunction · 0.90

Tested by

no test coverage detected