Example #1
0
    def test_calculate_matches_complex(self):
        auto = EPGProfile.from_file(example_file('Ap10-haba-auto.csv'))
        manual = EPGProfile.from_file(example_file('Ap10-haba-manual.csv'))
        stats = EPGComparator((auto, manual)).compare()

        expected = dict(
            c=dict(n=71, full_matches=45, loffset=.01, roffset=.02),
            pd=dict(n=49, full_matches=37, loffset=0., roffset=.04),
            np=dict(n=22, full_matches=20, loffset=.02, roffset=0.))
        for waveform in expected:
            for name, val in expected[waveform].items():
                self.assertAlmostEqual(val, stats.get(waveform, mean)[name],
                                       2, name)
Example #2
0
    def test_calculate_matches(self):
        auto = EPGProfile.from_file(example_file('Ap1-haba-auto.csv'))
        manual = EPGProfile.from_file(example_file('Ap1-haba-manual.csv'))
        stats = EPGComparator((auto, manual)).compare()

        expected = dict(
            c=dict(n=33, full_matches=21, loffset=.03, roffset=.06),
            pd=dict(n=16, full_matches=8, loffset=0., roffset=0.),
            np=dict(n=26, full_matches=20, loffset=.13, roffset=.04))
        for waveform in expected:
            for name, val in expected[waveform].items():
                self.assertAlmostEqual(val, stats.get(waveform, mean)[name],
                                       2, name)
Example #3
0
 def test_creating_confusion_matrix(self):
     profile = EPGProfile.from_file(example_file('simple-manual.csv'))
     other = EPGProfile.from_file(example_file('simple-auto.csv'))
     stats = EPGComparator((profile, other)).compare()
     self.assertSequenceEqual(
         (1953, 2, 0, 6, 1677, 0, 450, 0, 316),
         tuple(stats.cfm))
     self.assertEqual(2409, sum(stats.cfm.column('c')))
     self.assertEqual(1679, sum(stats.cfm.column('np')))
     self.assertEqual(316, sum(stats.cfm.column('pd')))
Example #4
0
 def test_calculate_offset(self):
     auto = EPGProfile.from_file(example_file('simple-auto.csv'))
     manual = EPGProfile.from_file(example_file('simple-manual.csv'))
     auto, manual = _EPGFingerprint(auto), _EPGFingerprint(manual)
     expected = dict(
         pd=[[20], [10]],
         c=[[10, 0], [-446, 2]],
         np=[[-6, 2], [0, 0]])
     offsets = EPGComparator._calculate_offsets((auto, manual),
                                                fractional=False)
     self.assertDictEqual(expected, offsets)