Exemplo n.º 1
0
    def test_jumpToSeefloorSlice_fractionalFrameWithoutBadBlocks(self):
        # Setup
        pixels_in_frame = Frame.FRAME_HEIGHT
        pixels_in_half_frame = int(pixels_in_frame / 2)

        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 0)
        drifts_df = self.__append_to_drifts_df(drifts_df, 200, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 300, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 400, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 500, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 600, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 700, 0,
                                               pixels_in_half_frame)
        driftData = DriftData(drifts_df)

        badframesData = BadFramesData(None, None)
        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise

        # Assert
        self.assertEqual(300, seeFloor.jumpToSeefloorSlice(200, 0.5))
        self.assertEqual(267, seeFloor.jumpToSeefloorSlice(200, 0.33333))
        self.assertEqual(350, seeFloor.jumpToSeefloorSlice(200, 0.75))
        self.assertEqual(450, seeFloor.jumpToSeefloorSlice(200, 1.25))
        self.assertEqual(500, seeFloor.jumpToSeefloorSlice(200, 1.5))

        self.assertEqual(500, seeFloor.jumpToSeefloorSlice(600, -0.5))
        self.assertEqual(290, seeFloor.jumpToSeefloorSlice(600, -1.55))
 def test_isBadFrame_emptyDF(self):
     # Setup
     badframesData = BadFramesData.createFromDataFrame(None, None)
     # Exercise
     # Assert
     self.assertFalse(badframesData.is_bad_frame(50))
     self.assertEqual(55, badframesData.firstGoodFrameAfter(55))
     self.assertEqual(45, badframesData.firstGoodFrameBefore(45))
    def test_isBadFrame(self):
        # Setup
        badframes_df = pd.DataFrame()
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(99),
                BadFramesData.COLNAME_endFrameNumber: 101
            },
            ignore_index=True)
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(44),
                BadFramesData.COLNAME_endFrameNumber: 46
            },
            ignore_index=True)

        #single BadFrame
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(222),
                BadFramesData.COLNAME_endFrameNumber: 222
            },
            ignore_index=True)

        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # Exercise
        # Assert

        # --- first BadFrame range
        self.assertFalse(badframesData.is_bad_frame(42))
        self.assertFalse(badframesData.is_bad_frame(43))

        self.assertTrue(badframesData.is_bad_frame(44))
        self.assertTrue(badframesData.is_bad_frame(45))
        self.assertTrue(badframesData.is_bad_frame(46))

        self.assertFalse(badframesData.is_bad_frame(47))
        self.assertFalse(badframesData.is_bad_frame(48))
        self.assertFalse(badframesData.is_bad_frame(49))

        #--- second BadFrame range
        self.assertFalse(badframesData.is_bad_frame(97))
        self.assertFalse(badframesData.is_bad_frame(98))

        self.assertTrue(badframesData.is_bad_frame(99))
        self.assertTrue(badframesData.is_bad_frame(100))
        self.assertTrue(badframesData.is_bad_frame(101))

        self.assertFalse(badframesData.is_bad_frame(102))
        self.assertFalse(badframesData.is_bad_frame(103))

        #--- third BadFrame range
        self.assertFalse(badframesData.is_bad_frame(220))
        self.assertFalse(badframesData.is_bad_frame(221))
        self.assertTrue(badframesData.is_bad_frame(222))
        self.assertFalse(badframesData.is_bad_frame(223))
        self.assertFalse(badframesData.is_bad_frame(224))
Exemplo n.º 4
0
    def test_jumpToSeefloorSlice_badFramesEmpty(self):
        # Setup
        pixels_in_frame = Frame.FRAME_HEIGHT
        pixels_in_half_frame = int(pixels_in_frame / 2)

        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 0)
        drifts_df = self.__append_to_drifts_df(drifts_df, 200, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 300, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 400, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 500, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 600, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 700, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 800, 0,
                                               pixels_in_half_frame)
        driftData = DriftData(drifts_df)

        #badframes_df = pd.DataFrame()
        badframes_df = BadFramesData.create_empty_df()
        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # --- good frames are 150-574 and 625-689. startFrame is 100, endFrame is 700

        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise
        # Assert
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(
            10, 1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, 1))
        self.assertEqual(300, seeFloor.jumpToSeefloorSlice(100, 1))
        self.assertEqual(600, seeFloor.jumpToSeefloorSlice(200, 2))
        self.assertEqual(600, seeFloor.jumpToSeefloorSlice(800, -1))
        self.assertEqual(400, seeFloor.jumpToSeefloorSlice(800, -2))
        self.assertEqual(500, seeFloor.jumpToSeefloorSlice(700, -1))
        self.assertEqual(300, seeFloor.jumpToSeefloorSlice(700, -2))
    def test_isBadFrame_overlapingEntries(self):
        # Setup
        badframes_df = pd.DataFrame()

        #two partially overlapping bad frame ranges
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(10),
                BadFramesData.COLNAME_endFrameNumber: 26
            },
            ignore_index=True)
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(24),
                BadFramesData.COLNAME_endFrameNumber: 28
            },
            ignore_index=True)

        #bad frame range that is fully inside the first bad frame range
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(10),
                BadFramesData.COLNAME_endFrameNumber: 16
            },
            ignore_index=True)

        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # Exercise

        # Assert

        # --- check values inside and outsidefully enclosed range
        self.assertTrue(badframesData.is_bad_frame(12))
        self.assertTrue(badframesData.is_bad_frame(13))
        self.assertTrue(badframesData.is_bad_frame(14))
        self.assertTrue(badframesData.is_bad_frame(15))
        self.assertTrue(badframesData.is_bad_frame(16))
        self.assertTrue(badframesData.is_bad_frame(17))

        # --- check values inside overlap of the partially overlapping range
        self.assertTrue(badframesData.is_bad_frame(23))
        self.assertTrue(badframesData.is_bad_frame(24))
        self.assertTrue(badframesData.is_bad_frame(25))
        self.assertTrue(badframesData.is_bad_frame(26))
        self.assertTrue(badframesData.is_bad_frame(27))
        self.assertTrue(badframesData.is_bad_frame(28))

        self.assertFalse(badframesData.is_bad_frame(29))
        self.assertFalse(badframesData.is_bad_frame(30))

        self.assertFalse(badframesData.is_bad_frame(9))
        self.assertFalse(badframesData.is_bad_frame(8))
Exemplo n.º 6
0
    def createFromFolderStruct(folderStruct):
        # type: (FolderStructure) -> SeeFloor

        driftsData = DriftData.createFromFolderStruct(folderStruct)
        badFramesData = BadFramesData.createFromFolderStruct(folderStruct)
        redDotsData = RedDotsData.createFromFolderStruct(folderStruct)

        filepath = folderStruct.getSeefloorFilepath()
        if folderStruct.fileExists(filepath):
            df = PandasWrapper.readDataFrameFromCSV(filepath)
        else:
            df = None
        newObj = SeeFloor(driftsData, badFramesData, redDotsData, folderStruct,
                          df)
        return newObj
    def test_firstGoodFrameBefore(self):
        # Setup
        badframes_df = pd.DataFrame()
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(99),
                BadFramesData.COLNAME_endFrameNumber: 101
            },
            ignore_index=True)
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(44),
                BadFramesData.COLNAME_endFrameNumber: 46
            },
            ignore_index=True)

        #single BadFrame
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(222),
                BadFramesData.COLNAME_endFrameNumber: 222
            },
            ignore_index=True)

        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # Exercise

        # Assert

        # --- first BadFrame range
        self.assertEqual(badframesData.firstGoodFrameBefore(42), 42)
        self.assertEqual(badframesData.firstGoodFrameBefore(43), 43)
        self.assertEqual(badframesData.firstGoodFrameBefore(44), 43)
        self.assertEqual(badframesData.firstGoodFrameBefore(46), 43)
        self.assertEqual(badframesData.firstGoodFrameBefore(47), 47)

        self.assertEqual(badframesData.firstGoodFrameBefore(98), 98)
        self.assertEqual(badframesData.firstGoodFrameBefore(99), 98)
        self.assertEqual(badframesData.firstGoodFrameBefore(100), 98)
        self.assertEqual(badframesData.firstGoodFrameBefore(101), 98)
        self.assertEqual(badframesData.firstGoodFrameBefore(102), 102)
        self.assertEqual(badframesData.firstGoodFrameBefore(103), 103)

        self.assertEqual(badframesData.firstGoodFrameBefore(221), 221)
        self.assertEqual(badframesData.firstGoodFrameBefore(222), 221)
        self.assertEqual(badframesData.firstGoodFrameBefore(223), 223)
Exemplo n.º 8
0
    def test_maxFrameID_noBadFrames(self):
        # Setup
        drifts_df = pd.DataFrame()

        drifts_df = self.__append_to_drifts_df(drifts_df, 95, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 98, 0, 16)
        driftData = DriftData(drifts_df)

        badframesData = BadFramesData(None, None)
        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise
        maxFrameID = seeFloor.maxFrameID()
        minFrameID = seeFloor.minFrameID()

        # Assert
        self.assertEqual(minFrameID, 95)
        self.assertEqual(maxFrameID, 100)
Exemplo n.º 9
0
    def test_maxFrameID_badFramesAtTheEnd(self):
        # Setup
        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 95, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 98, 0, 16)
        driftData = DriftData(drifts_df)

        badframes_df = pd.DataFrame()
        badframes_df = self.__append_to_badframes_df(badframes_df, 99, 101)
        badframes_df = self.__append_to_badframes_df(badframes_df, 92, 95)
        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise
        minFrameID = seeFloor.minFrameID()
        maxFrameID = seeFloor.maxFrameID()

        # Assert
        self.assertEqual(minFrameID, 96)
        self.assertEqual(maxFrameID, 98)
Exemplo n.º 10
0
    def __init__(self, imageWin, folderStruct, videoStream, driftData):
        # type: (ImageWindow, FolderStructure, VideoStream, DriftData) -> ScientistUI

        self.__zoom = False
        self.__markingDrift = False
        self.__contrastLevel = self.CONTRAST_NORMAL
        self.__imageWin = imageWin
        self.__folderStruct = folderStruct
        self.__videoStream = videoStream

        self.__driftData = driftData
        self.__badFramesData = BadFramesData.createFromFolderStruct(
            folderStruct)
        self.__redDotsData = RedDotsData.createFromFolderStruct(folderStruct)

        self.__seeFloor = SeeFloor.createFromFolderStruct(folderStruct)
        self.__seeFloorNoBadBlocks = SeeFloorNoBadBlocks.createFromFolderStruct(
            folderStruct)

        self.__crabData = CrabsData(self.__folderStruct)
        self.__redDotsUI = RedDotsUI(self.__videoStream)
        self.__markersData = MarkersData(folderStruct)
        self.__marker_id = "0"
    def test_firstBadFrame_BeforeAndAfter_overlapingEntries(self):
        # Setup
        badframes_df = pd.DataFrame()

        # two partially overlapping bad frame ranges
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(10),
                BadFramesData.COLNAME_endFrameNumber: 26
            },
            ignore_index=True)
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(24),
                BadFramesData.COLNAME_endFrameNumber: 30
            },
            ignore_index=True)

        # bad frame range that is fully inside the first bad frame range
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(23),
                BadFramesData.COLNAME_endFrameNumber: 27
            },
            ignore_index=True)

        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # Exercise

        # Assert

        # --- check values inside and outsidefully enclosed range
        self.assertEqual(8, badframesData.firstBadFrameBefore(8))
        self.assertEqual(9, badframesData.firstBadFrameBefore(9))
        self.assertEqual(10, badframesData.firstBadFrameBefore(10))
        self.assertEqual(11, badframesData.firstBadFrameBefore(11))
        self.assertEqual(12, badframesData.firstBadFrameBefore(12))
        self.assertEqual(13, badframesData.firstBadFrameBefore(13))
        self.assertEqual(14, badframesData.firstBadFrameBefore(14))
        self.assertEqual(15, badframesData.firstBadFrameBefore(15))
        self.assertEqual(16, badframesData.firstBadFrameBefore(16))
        self.assertEqual(17, badframesData.firstBadFrameBefore(17))
        self.assertEqual(18, badframesData.firstBadFrameBefore(18))
        self.assertEqual(19, badframesData.firstBadFrameBefore(19))
        self.assertEqual(20, badframesData.firstBadFrameBefore(20))
        self.assertEqual(21, badframesData.firstBadFrameBefore(21))
        self.assertEqual(22, badframesData.firstBadFrameBefore(22))
        self.assertEqual(23, badframesData.firstBadFrameBefore(23))
        self.assertEqual(24, badframesData.firstBadFrameBefore(24))
        self.assertEqual(25, badframesData.firstBadFrameBefore(25))
        self.assertEqual(26, badframesData.firstBadFrameBefore(26))
        self.assertEqual(27, badframesData.firstBadFrameBefore(27))
        self.assertEqual(28, badframesData.firstBadFrameBefore(28))
        self.assertEqual(29, badframesData.firstBadFrameBefore(29))
        self.assertEqual(30, badframesData.firstBadFrameBefore(30))
        self.assertEqual(
            30, badframesData.firstBadFrameBefore(31))  #<-- special case
        self.assertEqual(
            30, badframesData.firstBadFrameBefore(32))  #<-- special case

        self.assertEqual(
            10, badframesData.firstBadFrameAfter(8))  #<-- special case
        self.assertEqual(
            10, badframesData.firstBadFrameAfter(9))  #<-- special case
        self.assertEqual(10, badframesData.firstBadFrameAfter(10))
        self.assertEqual(11, badframesData.firstBadFrameAfter(11))
        self.assertEqual(12, badframesData.firstBadFrameAfter(12))
        self.assertEqual(13, badframesData.firstBadFrameAfter(13))
        self.assertEqual(14, badframesData.firstBadFrameAfter(14))
        self.assertEqual(15, badframesData.firstBadFrameAfter(15))
        self.assertEqual(16, badframesData.firstBadFrameAfter(16))
        self.assertEqual(17, badframesData.firstBadFrameAfter(17))
        self.assertEqual(18, badframesData.firstBadFrameAfter(18))
        self.assertEqual(19, badframesData.firstBadFrameAfter(19))
        self.assertEqual(20, badframesData.firstBadFrameAfter(20))
        self.assertEqual(21, badframesData.firstBadFrameAfter(21))
        self.assertEqual(22, badframesData.firstBadFrameAfter(22))
        self.assertEqual(23, badframesData.firstBadFrameAfter(23))
        self.assertEqual(24, badframesData.firstBadFrameAfter(24))
        self.assertEqual(25, badframesData.firstBadFrameAfter(25))
        self.assertEqual(26, badframesData.firstBadFrameAfter(26))
        self.assertEqual(27, badframesData.firstBadFrameAfter(27))
        self.assertEqual(28, badframesData.firstBadFrameAfter(28))
        self.assertEqual(29, badframesData.firstBadFrameAfter(29))
        self.assertEqual(30, badframesData.firstBadFrameAfter(30))
        self.assertEqual(31, badframesData.firstBadFrameAfter(31))
        self.assertEqual(32, badframesData.firstBadFrameAfter(32))
    def test_firstBadFrame_AfterAndBefore_nonOverlaptingRanges(self):
        # Setup
        badframes_df = pd.DataFrame()
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(99),
                BadFramesData.COLNAME_endFrameNumber: 101
            },
            ignore_index=True)
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(44),
                BadFramesData.COLNAME_endFrameNumber: 46
            },
            ignore_index=True)

        #single BadFrame
        badframes_df = badframes_df.append(
            {
                BadFramesData.COLNAME_startfFrameNumber: int(222),
                BadFramesData.COLNAME_endFrameNumber: 222
            },
            ignore_index=True)

        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        # Exercise

        # Assert

        # --- first BadFrame range
        self.assertEqual(44, badframesData.firstBadFrameAfter(41))
        self.assertEqual(44, badframesData.firstBadFrameAfter(42))
        self.assertEqual(44, badframesData.firstBadFrameAfter(43))
        self.assertEqual(
            44, badframesData.firstBadFrameAfter(44))  #<-- 44 is bad frame
        self.assertEqual(
            45, badframesData.firstBadFrameAfter(45))  #<-- 45 is bad frame
        self.assertEqual(
            46, badframesData.firstBadFrameAfter(46))  #<-- 46 is bad frame
        self.assertEqual(99, badframesData.firstBadFrameAfter(47))
        self.assertEqual(99, badframesData.firstBadFrameAfter(98))
        self.assertEqual(
            99, badframesData.firstBadFrameAfter(99))  #<-- 99 is bad frame
        self.assertEqual(
            100, badframesData.firstBadFrameAfter(100))  #<-- 100 is bad frame
        self.assertEqual(
            101, badframesData.firstBadFrameAfter(101))  #<-- 101 is bad frame
        self.assertEqual(222, badframesData.firstBadFrameAfter(102))
        self.assertEqual(222, badframesData.firstBadFrameAfter(103))
        self.assertEqual(222, badframesData.firstBadFrameAfter(220))
        self.assertEqual(222, badframesData.firstBadFrameAfter(221))
        self.assertEqual(
            222, badframesData.firstBadFrameAfter(222))  #<-- 222 is bad frame
        self.assertEqual(223, badframesData.firstBadFrameAfter(223))

        self.assertEqual(41, badframesData.firstBadFrameBefore(41))
        self.assertEqual(42, badframesData.firstBadFrameBefore(42))
        self.assertEqual(43, badframesData.firstBadFrameBefore(43))
        self.assertEqual(
            44, badframesData.firstBadFrameBefore(44))  #<-- 44 is bad frame
        self.assertEqual(
            45, badframesData.firstBadFrameBefore(45))  #<-- 45 is bad frame
        self.assertEqual(
            46, badframesData.firstBadFrameBefore(46))  #<-- 46 is bad frame
        self.assertEqual(46, badframesData.firstBadFrameBefore(47))
        self.assertEqual(46, badframesData.firstBadFrameBefore(48))
        self.assertEqual(46, badframesData.firstBadFrameBefore(49))
        self.assertEqual(46, badframesData.firstBadFrameBefore(97))
        self.assertEqual(46, badframesData.firstBadFrameBefore(98))
        self.assertEqual(
            99, badframesData.firstBadFrameBefore(99))  #<-- 99 is bad frame
        self.assertEqual(
            100, badframesData.firstBadFrameBefore(100))  #<-- 100 is bad frame
        self.assertEqual(
            101, badframesData.firstBadFrameBefore(101))  #<-- 101 is bad frame
        self.assertEqual(101, badframesData.firstBadFrameBefore(102))
        self.assertEqual(101, badframesData.firstBadFrameBefore(103))
        self.assertEqual(101, badframesData.firstBadFrameBefore(220))
        self.assertEqual(101, badframesData.firstBadFrameBefore(221))
        self.assertEqual(
            222, badframesData.firstBadFrameBefore(222))  #<-- 222 is bad frame
        self.assertEqual(222, badframesData.firstBadFrameBefore(223))
        self.assertEqual(222, badframesData.firstBadFrameBefore(224))
Exemplo n.º 13
0
    def test_jumpToSeefloorSlice(self):
        # Setup
        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 93, 0, 0)
        drifts_df = self.__append_to_drifts_df(drifts_df, 95, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 102, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 98, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 104, 0, 16)
        drifts_df = self.__append_to_drifts_df(drifts_df, 107, 0, 16)
        driftData = DriftData(drifts_df)

        badframes_df = pd.DataFrame()
        badframes_df = self.__append_to_badframes_df(badframes_df, 99, 101)
        badframes_df = self.__append_to_badframes_df(badframes_df, 104, 108)
        badframes_df = self.__append_to_badframes_df(badframes_df, 92, 95)
        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        #--- good frames are 96,97,98 and 102,103. startFrame is 93, endFrame is 107

        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise

        # Assert
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            -333, 1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(91, 1))
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(92, 1))
        self.assertEqual(96, seeFloor.jumpToSeefloorSlice(93, 1))
        self.assertEqual(96, seeFloor.jumpToSeefloorSlice(94, 1))
        self.assertEqual(96, seeFloor.jumpToSeefloorSlice(95, 1))
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(96, 1))
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(97, 1))
        self.assertEqual(102, seeFloor.jumpToSeefloorSlice(98, 1))
        self.assertEqual(102, seeFloor.jumpToSeefloorSlice(99, 1))
        self.assertEqual(102, seeFloor.jumpToSeefloorSlice(100, 1))
        self.assertEqual(102, seeFloor.jumpToSeefloorSlice(101, 1))
        self.assertEqual(103, seeFloor.jumpToSeefloorSlice(102, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(103, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(104, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(105, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(106, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(107, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(108, 1))
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(
            2222, 1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(109, 1))

        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            -333, -1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            91, -1))  #<-- out-of-bound frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            92, -1))  #<-- out-of-bound frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            93, -1))  #<-- 93 is bad frame - its FIRST frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            94, -1))  #<-- 94 is bad frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(
            95, -1))  #<-- 95 is bad frame
        self.assertEqual(93, seeFloor.jumpToSeefloorSlice(96, -1))
        self.assertEqual(96, seeFloor.jumpToSeefloorSlice(97, -1))
        self.assertEqual(96, seeFloor.jumpToSeefloorSlice(98, -1))
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(
            99, -1))  #<-- 99 is bad frame
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(
            100, -1))  #<-- 100 is bad frame
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(
            101, -1))  #<-- 101 is bad frame
        self.assertEqual(98, seeFloor.jumpToSeefloorSlice(102, -1))
        self.assertEqual(102, seeFloor.jumpToSeefloorSlice(103, -1))
        self.assertEqual(103, seeFloor.jumpToSeefloorSlice(
            104, -1))  #<-- 104 is bad frame
        self.assertEqual(103, seeFloor.jumpToSeefloorSlice(
            105, -1))  #<-- 105 is bad frame
        self.assertEqual(103, seeFloor.jumpToSeefloorSlice(
            106, -1))  #<-- 106 is bad frame
        self.assertEqual(103, seeFloor.jumpToSeefloorSlice(
            107, -1))  #<-- 107 is bad frame - its LAST frame
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(
            108, -1))  #<-- out-of-bound frame
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(
            2222, -1))  #<-- out-of-bound frame
        self.assertEqual(107, seeFloor.jumpToSeefloorSlice(
            109, -1))  #<-- out-of-bound frame
Exemplo n.º 14
0
    def test_jumpToSeefloorSlice_multiSlice_goingDownward(self):
        # Setup
        pixels_in_frame = Frame.FRAME_HEIGHT
        pixels_in_half_frame = int(pixels_in_frame / 2)

        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 0)
        drifts_df = self.__append_to_drifts_df(drifts_df, 200, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 300, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 400, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 500, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 600, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 700, 0,
                                               pixels_in_half_frame)
        driftData = DriftData(drifts_df)

        badframes_df = pd.DataFrame()
        badframes_df = self.__append_to_badframes_df(badframes_df, 90, 149)
        badframes_df = self.__append_to_badframes_df(badframes_df, 575, 624)
        badframes_df = self.__append_to_badframes_df(badframes_df, 690, 790)
        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        #--- good frames are 150-574 and 625-689. startFrame is 100, endFrame is 700

        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise
        # Assert
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(
            10, -1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, -1))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(100, -1))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(101, -1))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(149, -1))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(150, -1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(151, -1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(175, -1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(348, -1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(349, -1))
        self.assertEqual(151, seeFloor.jumpToSeefloorSlice(350, -1))
        self.assertEqual(152, seeFloor.jumpToSeefloorSlice(351, -1))
        self.assertEqual(374, seeFloor.jumpToSeefloorSlice(573, -1))
        self.assertEqual(375, seeFloor.jumpToSeefloorSlice(574, -1))  #<--- ??
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(575, -1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(576, -1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(623, -1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(624, -1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(625, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(626, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(627, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(687, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(688, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(689, -1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(690, -1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(691, -1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(699, -1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(700, -1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(701, -1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(702, -1))

        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(
            10, -2))  # if parameter is out of bounds show first/last frame
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, -2))

        # step 1 is to jump over bad block, step 2 is to jump 200 frames
        self.assertEqual(375, seeFloor.jumpToSeefloorSlice(600, -2))
        self.assertEqual(375, seeFloor.jumpToSeefloorSlice(575, -2))

        #TODO: why 176 and not 175? where did extra 1 come from
        self.assertEqual(176, seeFloor.jumpToSeefloorSlice(
            574, -2))  #<--- why 176 and not 175? where did extra 1 come from
        self.assertEqual(175, seeFloor.jumpToSeefloorSlice(573, -2))

        #TODO:fix test cases below
        # normal 2 jumps without any bad blocks in the middle
        self.assertEqual(152, seeFloor.jumpToSeefloorSlice(550, -2))
        self.assertEqual(151, seeFloor.jumpToSeefloorSlice(549, -2))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(548, -2))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(547, -2))
        self.assertEqual(
            150, seeFloor.jumpToSeefloorSlice(546, -2)
        )  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(
            150, seeFloor.jumpToSeefloorSlice(545, -2)
        )  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(
            150, seeFloor.jumpToSeefloorSlice(351, -2)
        )  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(350, -2))
        self.assertEqual(
            100, seeFloor.jumpToSeefloorSlice(349, -2)
        )  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(348, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(348, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(152, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(151, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(150, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(149, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(148, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(147, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(103, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(102, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(101, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(100, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(98, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(92, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(91, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(90, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(89, -2))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(88, -2))

        # jump #1 is 200 frames, then second jump is shorter to the last good frame before bad block

        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(700, -1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(700, -2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(700, -3))
        self.assertEqual(375, seeFloor.jumpToSeefloorSlice(700, -4))
        self.assertEqual(176, seeFloor.jumpToSeefloorSlice(
            700, -5))  #<-- ?? why not 175?
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(700, -6))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(700, -7))
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(700, -8))

        self.assertEqual(176, seeFloor.jumpToSeefloorSlice(699, -5))
        self.assertEqual(176, seeFloor.jumpToSeefloorSlice(698, -5))

        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(701, -1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(701, -2))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(701, -3))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(702, -3))
Exemplo n.º 15
0
    def test_jumpToSeefloorSlice_multiSlice_goingUpward(self):
        # Setup
        pixels_in_frame = Frame.FRAME_HEIGHT
        pixels_in_half_frame = int(pixels_in_frame / 2)

        drifts_df = pd.DataFrame()
        drifts_df = self.__append_to_drifts_df(drifts_df, 100, 0, 0)
        drifts_df = self.__append_to_drifts_df(drifts_df, 200, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 300, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 400, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 500, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 600, 0,
                                               pixels_in_half_frame)
        drifts_df = self.__append_to_drifts_df(drifts_df, 700, 0,
                                               pixels_in_half_frame)
        driftData = DriftData(drifts_df)

        badframes_df = pd.DataFrame()
        badframes_df = self.__append_to_badframes_df(badframes_df, 90, 149)
        badframes_df = self.__append_to_badframes_df(badframes_df, 575, 624)
        badframes_df = self.__append_to_badframes_df(badframes_df, 690, 790)
        badframesData = BadFramesData.createFromDataFrame(None, badframes_df)

        #--- good frames are 150-574 and 625-689. startFrame is 100, endFrame is 700

        seeFloor = SeeFloor(driftData, badframesData, None, None)

        # Exercise
        # Assert

        self.assertEqual(510, seeFloor.jumpToSeefloorSlice(500, 0.05))
        self.assertEqual(560, seeFloor.jumpToSeefloorSlice(500, 0.30))
        self.assertEqual(561, seeFloor.jumpToSeefloorSlice(500, 0.305))
        self.assertEqual(563, seeFloor.jumpToSeefloorSlice(500, 0.31))
        self.assertEqual(565, seeFloor.jumpToSeefloorSlice(500, 0.32))
        self.assertEqual(567, seeFloor.jumpToSeefloorSlice(500, 0.33))
        self.assertEqual(569, seeFloor.jumpToSeefloorSlice(500, 0.34))
        self.assertEqual(571, seeFloor.jumpToSeefloorSlice(500, 0.35))
        self.assertEqual(573, seeFloor.jumpToSeefloorSlice(500, 0.36))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(500, 0.37))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(500, 0.38))  #??
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(500, 0.39))  #??
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(500, 1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(500, 1.1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(500, 1.36))  #??
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(500, 1.39))  #??
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(500, 1.34))  #??
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(500, 2))  #??
        self.assertEqual(646, seeFloor.jumpToSeefloorSlice(500, 2.1))  #??

        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(
            10, 1))  # if parameter is out of bounds show first/last frame
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, 1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(100, 1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(101, 1))
        self.assertEqual(150, seeFloor.jumpToSeefloorSlice(149, 1))
        self.assertEqual(350, seeFloor.jumpToSeefloorSlice(150, 1))
        self.assertEqual(352, seeFloor.jumpToSeefloorSlice(151, 1))  #<>>>
        self.assertEqual(353, seeFloor.jumpToSeefloorSlice(152, 1))  #<>>>
        self.assertEqual(375, seeFloor.jumpToSeefloorSlice(175, 1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(572, 1))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(573, 1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(574, 1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(575, 1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(623, 1))
        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(624, 1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(625, 1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(626, 1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(627, 1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(687, 1))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(688, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(689, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(690, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(691, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(699, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(700, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(701, 1))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(702, 1))

        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(
            10, 2))  # if parameter is out of bounds show first/last frame
        self.assertEqual(100, seeFloor.jumpToSeefloorSlice(99, 2))

        # step 1 is to jump over bad block, step 2 is to jump 200 frames
        self.assertEqual(350, seeFloor.jumpToSeefloorSlice(100, 2))
        self.assertEqual(350, seeFloor.jumpToSeefloorSlice(101, 2))
        self.assertEqual(350, seeFloor.jumpToSeefloorSlice(149, 2))

        # normal 2 jumps without any bad blocks in the middle
        self.assertEqual(550, seeFloor.jumpToSeefloorSlice(150, 2))
        self.assertEqual(553, seeFloor.jumpToSeefloorSlice(151, 2))
        self.assertEqual(554, seeFloor.jumpToSeefloorSlice(152, 2))
        self.assertEqual(555, seeFloor.jumpToSeefloorSlice(153, 2))
        self.assertEqual(555, seeFloor.jumpToSeefloorSlice(
            154,
            2))  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(555, seeFloor.jumpToSeefloorSlice(
            155,
            2))  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(558, seeFloor.jumpToSeefloorSlice(156, 2))
        self.assertEqual(559, seeFloor.jumpToSeefloorSlice(157, 2))
        self.assertEqual(560, seeFloor.jumpToSeefloorSlice(158, 2))
        self.assertEqual(560, seeFloor.jumpToSeefloorSlice(
            159,
            2))  #<-- ?? why diff input but same output. Who is rounding where?
        self.assertEqual(560, seeFloor.jumpToSeefloorSlice(
            160,
            2))  #<-- ?? why diff input but same output. Who is rounding where?

        # jump #1 is 200 frames, then second jump is shorter to the last good frame before bad block

        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(172, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(173, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(174, 2))  #<-- ??
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(175, 2))  #<-- ??
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(176, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(177, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(178, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(179, 2))
        self.assertEqual(574, seeFloor.jumpToSeefloorSlice(180, 2))

        self.assertEqual(625, seeFloor.jumpToSeefloorSlice(180, 3))
        self.assertEqual(689, seeFloor.jumpToSeefloorSlice(180, 4))
        self.assertEqual(700, seeFloor.jumpToSeefloorSlice(180, 5))