aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_heatmaps.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test_heatmaps.py')
-rw-r--r--tests/unit/test_heatmaps.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/unit/test_heatmaps.py b/tests/unit/test_heatmaps.py
index 03fd4a6..8781d6f 100644
--- a/tests/unit/test_heatmaps.py
+++ b/tests/unit/test_heatmaps.py
@@ -1,5 +1,9 @@
"""Module contains tests for gn3.heatmaps.heatmaps"""
from unittest import TestCase
+
+import pytest
+from numpy.testing import assert_allclose
+
from gn3.heatmaps import (
cluster_traits,
get_loci_names,
@@ -24,7 +28,8 @@ slinked = (
class TestHeatmap(TestCase):
"""Class for testing heatmap computation functions"""
- def test_cluster_traits(self):
+ @pytest.mark.unit_test
+ def test_cluster_traits(self): # pylint: disable=R0201
"""
Test that the clustering is working as expected.
"""
@@ -39,7 +44,7 @@ class TestHeatmap(TestCase):
(6.84118, 7.08432, 7.59844, 7.08229, 7.26774, 7.24991),
(9.45215, 10.6943, 8.64719, 10.1592, 7.75044, 8.78615),
(7.04737, 6.87185, 7.58586, 6.92456, 6.84243, 7.36913)]
- self.assertEqual(
+ assert_allclose(
cluster_traits(traits_data_list),
((0.0, 0.20337048635536847, 0.16381088984330505, 1.7388553629398245,
1.5025235756329178, 0.6952839500255574, 1.271661230252733,
@@ -73,11 +78,13 @@ class TestHeatmap(TestCase):
1.7413442197913358, 0.33370067057028485, 1.3256191648260216,
0.0)))
+ @pytest.mark.unit_test
def test_compute_heatmap_order(self):
"""Test the orders."""
self.assertEqual(
compute_traits_order(slinked), (0, 2, 1, 7, 5, 9, 3, 6, 8, 4))
+ @pytest.mark.unit_test
def test_retrieve_samples_and_values(self):
"""Test retrieval of samples and values."""
for orders, slist, tdata, expected in [
@@ -103,6 +110,7 @@ class TestHeatmap(TestCase):
self.assertEqual(
retrieve_samples_and_values(orders, slist, tdata), expected)
+ @pytest.mark.unit_test
def test_get_lrs_from_chr(self):
"""Check that function gets correct LRS values"""
for trait, chromosome, expected in [
@@ -117,6 +125,7 @@ class TestHeatmap(TestCase):
with self.subTest(trait=trait, chromosome=chromosome):
self.assertEqual(get_lrs_from_chr(trait, chromosome), expected)
+ @pytest.mark.unit_test
def test_process_traits_data_for_heatmap(self):
"""Check for correct processing of data for heatmap generation."""
self.assertEqual(
@@ -129,6 +138,7 @@ class TestHeatmap(TestCase):
[[0.5, 0.579, 0.5],
[0.5, 0.5, 0.5]]])
+ @pytest.mark.unit_test
def test_get_loci_names(self):
"""Check that loci names are retrieved correctly."""
for organised, expected in (