示例#1
0
    def test_constructor_logging(self, _):
        """Test that the constructor logs messages."""
        fake_results = Mock(summary=Mock(side_effect=ValueWarning("test")))

        with self.assertLogs(logger="forecast.forecast",
                             level=logging.WARNING):
            LinearForecastResult(fake_results)
示例#2
0
    def test_pvalues_slope_list(self, _):
        """Test the slope and pvalues properties."""
        fake_results = Mock(summary=Mock(return_value="test"),
                            pvalues=Mock(tolist=Mock(return_value=[0, 1, 2])),
                            params=[3, 4, 5])

        lfr = LinearForecastResult(fake_results)

        self.assertEqual(lfr.pvalues, [0, 1, 2])
        self.assertEqual(lfr.slope, [3, 4, 5])
示例#3
0
    def test_pvalues_slope_single(self, _):
        """Test the slope and pvalues properties."""
        fake_results = Mock(
            summary=Mock(return_value="test"),
            pvalues=Mock(tolist=Mock(return_value=["test_pvalues"])),
            params=["test_slope"],
        )

        lfr = LinearForecastResult(fake_results)

        self.assertEqual(lfr.pvalues, "test_pvalues")
        self.assertEqual(lfr.slope, "test_slope")
示例#4
0
    def test_pvalues_slope_intercept(self, _):
        """Test the slope, intercept, and pvalues properties."""
        fake_results = Mock(
            summary=Mock(return_value="this is a test summary"),
            pvalues=Mock(tolist=Mock(return_value=[99999, 88888])),
            params=[66666, 77777],
        )

        lfr = LinearForecastResult(fake_results)

        self.assertEqual(lfr.pvalues, ["99999.00000000", "88888.00000000"])
        self.assertEqual(lfr.slope, 77777)
        self.assertEqual(lfr.intercept, 66666)