From 88114e9bee5f9c821166abf3b2af3465364abcc0 Mon Sep 17 00:00:00 2001 From: smathot Date: Fri, 26 May 2023 13:44:15 +0200 Subject: [PATCH] unittest: add cluster detection --- unittests/test_tst.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/unittests/test_tst.py b/unittests/test_tst.py index aea64a3..3203a32 100644 --- a/unittests/test_tst.py +++ b/unittests/test_tst.py @@ -2,7 +2,7 @@ import os import math import numpy as np -from datamatrix import io +from datamatrix import io, DataMatrix, MultiDimensionalColumn def _test_indices(fnc): @@ -39,3 +39,14 @@ def test_find(): assert math.isclose(results['set_size'].p, 4.68068027552196e-63) assert math.isclose(results['set_size:color_type[T.proto]'].p, 0.013513332566898819) + + +def test_clusters(): + rm = DataMatrix(length=1) + rm.p = MultiDimensionalColumn(shape=8) + rm.p = 1, 0, 0, 0, 1, 1, 0, 0 + rm.z = MultiDimensionalColumn(shape=8) + rm.z = 0, 1, 1, -1, 0, 0, -1, -1 + rm.effect = 'dummy' + assert tst._clusters(rm, .05) == { + 'dummy': [(1, 3, 2.0), (6, 8, 2.0), (3, 4, 1.0)]}