예제 #1
0
    def test_intradayStats(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateIntradayStats([data1, data2])

        self.assertEqual(stats.iloc[0].name, datetime.date(2016, 3, 21))
        self.assertEqual(stats.iloc[1].name, datetime.date(2016, 3, 22))
예제 #2
0
    def test_intradayStats(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateIntradayStats([data1, data2])

        self.assertEqual(stats.iloc[0].name, datetime.date(2016, 3, 21))
        self.assertEqual(stats.iloc[1].name, datetime.date(2016, 3, 22))
예제 #3
0
    def test_plottingOnIntradayStats(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateStatsFrom([data1, data2],
                                             sleepStats.STATS_NAME_INTRADAY)

        data = stats.apply(pd.value_counts)
        mplot.plotSleepValueHeatmap(data, sleepValue=1)
예제 #4
0
    def test_plottingOnIntradayStats(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateStatsFrom([data1, data2],
                                             sleepStats.STATS_NAME_INTRADAY)

        data = stats.apply(pd.value_counts)
        mplot.plotSleepValueHeatmap(data, sleepValue=1)
예제 #5
0
    def test_intervalsStats(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_intervals01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_intervals02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateIntervalsStats([data1, data2], 5)

        self.assertEqual(stats.iloc[0][0], 5)
        self.assertEqual(stats.iloc[0][1], 8)
        self.assertEqual(stats.iloc[0][2], 8)
        self.assertEqual(stats.iloc[1][0], 6)
        self.assertEqual(stats.iloc[1][1], 5)
        self.assertEqual(stats.iloc[1][2], 8)
        self.assertEqual(stats.iloc[1][3], 11)
예제 #6
0
    def test_intervalsStats(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_intervals01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_intervals02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateIntervalsStats([data1, data2], 5)

        self.assertEqual(stats.iloc[0][0], 5)
        self.assertEqual(stats.iloc[0][1], 8)
        self.assertEqual(stats.iloc[0][2], 8)
        self.assertEqual(stats.iloc[1][0], 6)
        self.assertEqual(stats.iloc[1][1], 5)
        self.assertEqual(stats.iloc[1][2], 8)
        self.assertEqual(stats.iloc[1][3], 11)
예제 #7
0
    def test_plottingOnBasicStats(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateStatsFrom([data1, data2],
                                             sleepStats.STATS_NAME_BASIC_AND_TIMING).reset_index()
        stats['date'] = pd.to_datetime(stats['date'])

        mplot.plotYearAndMonthStatsSleep(stats)
        mplot.plotPreliminaryStats(stats)
        mplot.plotWeekdayStatsSleep(stats)
        mplot.plotDailyStatsSleep(stats)
        mplot.plotMonthlyStatsSleep(stats)
예제 #8
0
    def test_plottingOnBasicStats(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic01.csv"
        data1 = utils.loadIntradayData(filepath)
        filepath = RESOURCE_PATH + "\\unittest\\test_sleep_basic02.csv"
        data2 = utils.loadIntradayData(filepath)
        stats = sleepStats.generateStatsFrom(
            [data1, data2],
            sleepStats.STATS_NAME_BASIC_AND_TIMING).reset_index()
        stats['date'] = pd.to_datetime(stats['date'])

        mplot.plotYearAndMonthStatsSleep(stats)
        mplot.plotPreliminaryStats(stats)
        mplot.plotWeekdayStatsSleep(stats)
        mplot.plotDailyStatsSleep(stats)
        mplot.plotMonthlyStatsSleep(stats)
예제 #9
0
    def test_basicStats(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_hb_basic01.csv"
        data = utils.loadIntradayData(filepath).set_index('datetime')
        stats = hbStats.groupByBasicStats(pd.TimeGrouper(freq='d'), data)

        self.assertEqual(stats.iloc[0]['count'], 16)
        self.assertEqual(stats.iloc[0]['max'], 70)
        self.assertEqual(stats.iloc[0]['min'], 50)
        self.assertEqual(stats.iloc[0]['mean'], 60)
예제 #10
0
    def test_basicStats(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_hb_basic01.csv"
        data = utils.loadIntradayData(filepath).set_index('datetime')
        stats = hbStats.groupByBasicStats(pd.TimeGrouper(freq='d'), data)

        self.assertEqual(stats.iloc[0]['count'], 16)
        self.assertEqual(stats.iloc[0]['max'], 70)
        self.assertEqual(stats.iloc[0]['min'], 50)
        self.assertEqual(stats.iloc[0]['mean'], 60)
예제 #11
0
    def test_minMax(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_hb_basic01.csv"
        data = utils.loadIntradayData(filepath).set_index('datetime')
        stats = hbStats.getMaxValues(data, 2)

        self.assertEqual(stats.iloc[0].value, 70)
        self.assertEqual(stats.iloc[1].value, 60)

        stats = hbStats.getMinValues(data, 2)

        self.assertEqual(stats.iloc[0].value, 50)
        self.assertEqual(stats.iloc[1].value, 60)
예제 #12
0
    def test_minMax(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_hb_basic01.csv"
        data = utils.loadIntradayData(filepath).set_index('datetime')
        stats = hbStats.getMaxValues(data, 2)

        self.assertEqual(stats.iloc[0].value, 70)
        self.assertEqual(stats.iloc[1].value, 60)

        stats = hbStats.getMinValues(data, 2)

        self.assertEqual(stats.iloc[0].value, 50)
        self.assertEqual(stats.iloc[1].value, 60)
예제 #13
0
    def test_firstMinuteAsleep(self):
        filepath = RESOURCE_PATH + "\\unittest\\test_sleepStats.csv"
        data = utils.loadIntradayData(filepath)
        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data)
        self.assertEqual(firstMinuteAsleep, 8)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 10)
        self.assertEqual(firstMinuteAsleep, 8)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 11)
        self.assertEqual(firstMinuteAsleep, 19)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 500)
        self.assertEqual(firstMinuteAsleep, None)
예제 #14
0
    def test_firstMinuteAsleep(self):
        filepath =  RESOURCE_PATH + "\\unittest\\test_sleepStats.csv"
        data = utils.loadIntradayData(filepath)
        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data)
        self.assertEqual(firstMinuteAsleep, 8)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 10)
        self.assertEqual(firstMinuteAsleep, 8)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 11)
        self.assertEqual(firstMinuteAsleep, 19)

        firstMinuteAsleep = sleepStats.getFirstMinuteAsleep(data, 500)
        self.assertEqual(firstMinuteAsleep, None)