MCPcopy
hub / github.com/stumpy-dev/stumpy / test_stimped_with_isconstant

Function test_stimped_with_isconstant

tests/test_stimp.py:345–399  ·  view source on GitHub ↗
(dask_cluster)

Source from the content-addressed store, hash-verified

343
344@pytest.mark.filterwarnings("ignore:\\s+Port 8787 is already in use:UserWarning")
345def test_stimped_with_isconstant(dask_cluster):
346 T = np.random.uniform(-1, 1, [64])
347 isconstant_func = functools.partial(
348 naive.isconstant_func_stddev_threshold, stddev_threshold=0.5
349 )
350
351 with Client(dask_cluster) as dask_client:
352 threshold = 0.2
353 min_m = 3
354 n = T.shape[0] - min_m + 1
355
356 pan = stimped(
357 dask_client,
358 T,
359 min_m=min_m,
360 max_m=None,
361 step=1,
362 # normalize=True,
363 T_subseq_isconstant_func=isconstant_func,
364 )
365
366 for i in range(n):
367 pan.update()
368
369 ref_PAN = np.full((pan.M_.shape[0], T.shape[0]), fill_value=np.inf)
370
371 for idx, m in enumerate(pan.M_[:n]):
372 zone = int(np.ceil(m / 4))
373 ref_mp = naive.stump(
374 T,
375 m,
376 T_B=None,
377 exclusion_zone=zone,
378 T_A_subseq_isconstant=isconstant_func,
379 )
380 ref_PAN[pan._bfs_indices[idx], : ref_mp.shape[0]] = ref_mp[:, 0]
381
382 # Compare raw pan
383 cmp_PAN = pan._PAN
384
385 naive.replace_inf(ref_PAN)
386 naive.replace_inf(cmp_PAN)
387
388 npt.assert_almost_equal(ref_PAN, cmp_PAN)
389
390 # Compare transformed pan
391 cmp_pan = pan.PAN_
392 ref_pan = naive.transform_pan(
393 pan._PAN, pan._M, threshold, pan._bfs_indices, pan._n_processed
394 )
395
396 naive.replace_inf(ref_pan)
397 naive.replace_inf(cmp_pan)
398
399 npt.assert_almost_equal(ref_pan, cmp_pan)

Callers

nothing calls this directly

Calls 2

stimpedClass · 0.90
updateMethod · 0.45

Tested by

no test coverage detected