Beispiel #1
0
    def test_invalid_formats(self):
        bad_formats = [
            "",
            "s",
            "ss",
            "ee",
            "E",
            "S123",
            "EE",
            "1:61:2",
            "01:-1:01",
            "05:002:59",
            "02:999:49",
            "1:02:61",
            "01:01:-1",
            "05:59:002",
            "02:49:999",
            ":02:03",
            "03::03",
            "04::",
            "::05",
            ":09:",
            "2:3.",
            "01:02.1000",
            "3:4.1234",
            "03:4.5432",
            "61:02.123",
            "6:61:341",
        ]

        for bad_format in bad_formats:
            rand_fs = random.randrange(100, 1000)
            with pytest.raises(ValueError):
                utils.wfdb_time_to_samples(bad_format, rand_fs)
Beispiel #2
0
 def test_mmssyyy(self):
     assert utils.wfdb_time_to_samples("2:3", self.fs) == int(123 * self.fs)
     assert utils.wfdb_time_to_samples("02:3", self.fs) == int(123 * self.fs)
     assert utils.wfdb_time_to_samples("2:03", self.fs) == int(123 * self.fs)
     assert utils.wfdb_time_to_samples("02:03", self.fs) == int(123 * self.fs)
     assert utils.wfdb_time_to_samples("2:3.4", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("2:3.40", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("2:3.400", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("2:03.400", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("02:3.400", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("02:03.400", self.fs) == int(123.4 * self.fs)
     assert utils.wfdb_time_to_samples("59:59.999", self.fs) == int(
         3599.999 * self.fs
     )
Beispiel #3
0
 def test_end_symbol(self):
     assert utils.wfdb_time_to_samples("e", 123) == -1
     assert utils.wfdb_time_to_samples("e", 321) == -1
Beispiel #4
0
 def test_hhmmss(self):
     assert utils.wfdb_time_to_samples("1:2:3", self.fs) == 3723 * self.fs
     assert utils.wfdb_time_to_samples("01:2:3", self.fs) == 3723 * self.fs
     assert utils.wfdb_time_to_samples("1:02:3", self.fs) == 3723 * self.fs
     assert utils.wfdb_time_to_samples("1:2:03", self.fs) == 3723 * self.fs
     assert utils.wfdb_time_to_samples("10:20:10", self.fs) == 37210 * self.fs
Beispiel #5
0
 def test_samples_string(self):
     assert utils.wfdb_time_to_samples("s234098234", 342) == 234098234
     assert utils.wfdb_time_to_samples("s123", 100) == 123
     assert utils.wfdb_time_to_samples("s0", 123) == 0