dmort27 / panphon

Python package and data files for manipulating phonological segments (phones, phonemes) in terms of universal phonological features.
MIT License
218 stars 45 forks source link

unittests #33

Closed martino-vic closed 2 years ago

martino-vic commented 2 years ago

21 out of 111 unittests are failing for me. They are all assertion errors where the predicted number seems to be off between 0.1 and 0.3, here's the full error message:

C:\Users\Viktor\Downloads\panphon-master\panphon\test>python -m unittest discover
...F.FF......FFFFFFFF..FF..FF...F.....F......................F...........F........F...........F................
======================================================================
FAIL: test_trivial1 (test_distance.TestHammingFeatureEditDistanceDivMaxlen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 82, in test_trivial1
    self.assertEqual(self.dist.hamming_feature_edit_distance_div_maxlen('pa', 'ba') * 22 * 2, 1)
AssertionError: 0.9166666666666666 != 1

======================================================================
FAIL: test_trivial3 (test_distance.TestHammingFeatureEditDistanceDivMaxlen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 88, in test_trivial3
    self.assertEqual(self.dist.hamming_feature_edit_distance_div_maxlen('sɛks', 'ɛɡz'), (1 + (1 / 22) + (1 / 22)) / 4)
AssertionError: 0.27083333333333337 != 0.2727272727272727

======================================================================
FAIL: test_trivial4 (test_distance.TestHammingFeatureEditDistanceDivMaxlen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 91, in test_trivial4
    self.assertEqual(self.dist.hamming_feature_edit_distance_div_maxlen('k', 'ɡ'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_feature_edit_distance (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 111, in test_feature_edit_distance
    self.assertEqual(self.dist.feature_edit_distance('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_feature_edit_distance_div_maxlen (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 117, in test_feature_edit_distance_div_maxlen
    self.assertEqual(self.dist.feature_edit_distance_div_maxlen('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_hamming_feature_edit_distance (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 123, in test_hamming_feature_edit_distance
    self.assertEqual(self.dist.hamming_feature_edit_distance('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_hamming_feature_edit_distance_div_maxlen (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 129, in test_hamming_feature_edit_distance_div_maxlen
    self.assertEqual(self.dist.hamming_feature_edit_distance_div_maxlen('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_jt_feature_edit_distance (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 114, in test_jt_feature_edit_distance
    self.assertEqual(self.dist.jt_feature_edit_distance('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_jt_feature_edit_distance_div_maxlen (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 120, in test_jt_feature_edit_distance_div_maxlen
    self.assertEqual(self.dist.jt_feature_edit_distance_div_maxlen('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_jt_hamming_feature_edit_distance (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 126, in test_jt_hamming_feature_edit_distance
    self.assertEqual(self.dist.jt_hamming_feature_edit_distance('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_jt_hamming_feature_edit_distance_div_maxlen (test_distance.TestMany)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 132, in test_jt_hamming_feature_edit_distance_div_maxlen
    self.assertEqual(self.dist.jt_hamming_feature_edit_distance_div_maxlen('p', 'b'), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_trivial1 (test_distance.TestUnweightedFeatureEditDist)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 44, in test_trivial1
    self.assertEqual(self.dist.feature_edit_distance('bim', 'pym') * 22, 3)
AssertionError: 2.75 != 3

======================================================================
FAIL: test_trivial2 (test_distance.TestUnweightedFeatureEditDist)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 47, in test_trivial2
    self.assertEqual(self.dist.feature_edit_distance('ti', 'tʰi') * 22, 1)
AssertionError: 0.9166666666666666 != 1

======================================================================
FAIL: test_xsampa (test_distance.TestUnweightedFeatureEditDist)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 50, in test_xsampa
    self.assertEqual(self.dist.feature_edit_distance('t i', 't_h i', xsampa=True) * 22, 1)
AssertionError: 0.9166666666666666 != 1

======================================================================
FAIL: test_xsampa2 (test_distance.TestUnweightedFeatureEditDist)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 53, in test_xsampa2
    self.assertEqual(self.dist.feature_edit_distance('p u n', 'p y n', xsampa=True) * 22, 1)
AssertionError: 0.9166666666666666 != 1

======================================================================
FAIL: test_feature_edit_distance (test_distance.TestXSampa)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_distance.py", line 147, in test_feature_edit_distance
    self.assertEqual(self.dist.feature_edit_distance("p_h", "p", xsampa=True), 1 / 22)
AssertionError: 0.041666666666666664 != 0.045454545454545456

======================================================================
FAIL: test_normalization (test_featuretable.TestFeatureTable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_featuretable.py", line 56, in test_normalization
    self.assertEqual(self.ft.longest_one_seg_prefix(u1), self.ft.longest_one_seg_prefix(u2))
AssertionError: '' != 'ũ'
+ ũ

======================================================================
FAIL: test_fts (test_panphon_methods.TestFeatureTableAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_panphon_methods.py", line 14, in test_fts
    self.assertEqual(len(self.ft.fts('u')), 22)
AssertionError: 24 != 22

======================================================================
FAIL: test_segment_to_vector (test_panphon_methods.TestFeatureTableAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_panphon_methods.py", line 78, in test_segment_to_vector
    self.assertEqual(len(self.ft.segment_to_vector('p')), 22)
AssertionError: 24 != 22

======================================================================
FAIL: test_fts (test_permissive_methods.TestFeatureTableAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_permissive_methods.py", line 14, in test_fts
    self.assertEqual(len(self.ft.fts('u')), 22)
AssertionError: 24 != 22

======================================================================
FAIL: test_segment_to_vector (test_permissive_methods.TestFeatureTableAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Viktor\Downloads\panphon-master\panphon\test\test_permissive_methods.py", line 78, in test_segment_to_vector
    self.assertEqual(len(self.ft.segment_to_vector('p')), 22)
AssertionError: 24 != 22

----------------------------------------------------------------------
Ran 111 tests in 43.522s

FAILED (failures=21)

C:\Users\Viktor\Downloads\panphon-master\panphon\test>
dmort27 commented 2 years ago

I have fixed the faulty tests (which mostly were assuming the wrong number of dimensions in the feature vector). I also eliminated one test that was not behaving as expected.