コード例 #1
0
 def test_symmetry(self):
     """Test that that accuracy between (A,B) and (B,A) is the same."""
     sequence1 = [1] * 10 + [2] * 20 + [3] * 30 + [4] * 40
     sequence2 = [1] * 10 + [2] * 20 + [3] * 30 + [4] * 40
     random.shuffle(sequence1)
     random.shuffle(sequence2)
     accuracy1 = evals.compute_sequence_match_accuracy(sequence1, sequence2)
     accuracy2 = evals.compute_sequence_match_accuracy(sequence2, sequence1)
     self.assertEqual(accuracy1, accuracy2)
コード例 #2
0
 def test_different_num_unique_ids(self):
     """Test for two sequences with different number of unique ids."""
     sequence1 = [1, 1]
     sequence2 = [1, 2]
     accuracy = evals.compute_sequence_match_accuracy(
         sequence1, sequence2)
     self.assertEqual(0.5, accuracy)
コード例 #3
0
 def test_equivalent_sequences(self):
     """Test for two sequences that are equivalent."""
     sequence1 = [0, 0, 1, 2, 2]
     sequence2 = [3, 3, 4, 1, 1]
     accuracy = evals.compute_sequence_match_accuracy(
         sequence1, sequence2)
     self.assertEqual(1.0, accuracy)
コード例 #4
0
 def test_mismatched_sequences(self):
     """Test for two sequences that are different."""
     sequence1 = [0, 0, 1, 2, 2]
     sequence2 = [3, 3, 4, 4, 1]
     accuracy = evals.compute_sequence_match_accuracy(
         sequence1, sequence2)
     self.assertEqual(0.8, accuracy)
コード例 #5
0
 def test_empty_sequences(self):
     """Test that empty sequences will raise error."""
     with self.assertRaises(Exception):
         evals.compute_sequence_match_accuracy([], [])
コード例 #6
0
 def test_sequences_of_different_lengths(self):
     """Test that sequences of different lengths will raise error."""
     sequence1 = [0, 0, 1, 2]
     sequence2 = [3, 3, 4, 4, 1]
     with self.assertRaises(Exception):
         evals.compute_sequence_match_accuracy(sequence1, sequence2)