Skip to content

Commit

Permalink
cov heu test
Browse files Browse the repository at this point in the history
  • Loading branch information
SkBlaz committed Aug 16, 2024
1 parent e339ee1 commit fadc249
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/cov_heu_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from __future__ import annotations

import sys
import unittest

import numpy as np

from outrank.algorithms.feature_ranking.ranking_cov_alignment import \
max_pair_coverage

np.random.seed(123)
sys.path.append('./outrank')


class TestMaxPairCoverage(unittest.TestCase):
def test_basic_functionality(self):
array1 = np.array([1, 2, 3, 1, 2])
array2 = np.array([4, 5, 6, 4, 5])
result = max_pair_coverage(array1, array2)
self.assertAlmostEqual(result, 2/5, places=5)

def test_identical_elements(self):
array1 = np.array([1, 1, 1, 1])
array2 = np.array([1, 1, 1, 1])
result = max_pair_coverage(array1, array2)
self.assertEqual(result, 1.0)

def test_large_arrays(self):
array1 = np.random.randint(0, 100, size=10000)
array2 = np.random.randint(0, 100, size=10000)
result = max_pair_coverage(array1, array2)
self.assertTrue(0 <= result <= 1)

def test_all_unique_pairs(self):
array1 = np.array([1, 2, 3, 4, 5])
array2 = np.array([6, 7, 8, 9, 10])
result = max_pair_coverage(array1, array2)
self.assertEqual(result, 1/5)

def test_all_same_pairs(self):
array1 = np.array([1, 1, 1, 1, 1])
array2 = np.array([2, 2, 2, 2, 2])
result = max_pair_coverage(array1, array2)
self.assertEqual(result, 1.0)

0 comments on commit fadc249

Please sign in to comment.