コード例 #1
0
    def test_chart_computes_sample_statistics(self):
        series = (1, 2, 2, 3, 3, 3, 2, 2, 1)
        chart = ControlChart(series)

        self.assertAlmostEqual(2.1111, chart.mean(), places=4)
        self.assertEquals(2, chart.median())
        self.assertAlmostEqual(0.78173, chart.std_dev(), places=3)
        self.assertEquals(len(series), chart.count())
コード例 #2
0
    def test_chart_computes_sample_statistics(self):
        series = (1, 2, 2, 3, 3, 3, 2, 2, 1)
        chart = ControlChart(series)

        self.assertAlmostEqual(2.1111, chart.mean(), places=4)
        self.assertEquals(2, chart.median())
        self.assertAlmostEqual(0.78173, chart.std_dev(), places=3)
        self.assertEquals(len(series), chart.count())
コード例 #3
0
    def test_series_under_control(self):
        chart = ControlChart(SERIES_UNDER_CONTROL)

        self.assertEquals(10.05, chart.mean())
        self.assertEquals(10.05, chart.median())
        self.assertAlmostEquals(0.8737, chart.std_dev(), places=4)

        self.assertAlmostEquals(7.429, chart.lower_control_limit(), places=3)
        self.assertAlmostEquals(12.671, chart.upper_control_limit(), places=3)

        self.assertEquals([], chart.points_outside_lcl())
        self.assertEquals([], chart.points_outside_ucl())
コード例 #4
0
    def test_series_under_control(self):
        chart = ControlChart(SERIES_UNDER_CONTROL)

        self.assertEquals(10.05, chart.mean())
        self.assertEquals(10.05, chart.median())
        self.assertAlmostEquals(0.8737, chart.std_dev(), places=4)

        self.assertAlmostEquals(7.429, chart.lower_control_limit(), places=3)
        self.assertAlmostEquals(12.671, chart.upper_control_limit(), places=3)

        self.assertEquals([], chart.points_outside_lcl())
        self.assertEquals([], chart.points_outside_ucl())
コード例 #5
0
    def test_data_series_is_analyzed(self):
        tf = tempfile.NamedTemporaryFile()
        control_chart = ControlChart(SERIES_UNDER_CONTROL)

        test_input = ""
        for val in SERIES_UNDER_CONTROL:
            test_input += " {} \n".format(str(val))

        tf.write(test_input)
        tf.flush()

        sys.argv = ["analyze_series", tf.name, "--verbose"]

        (status, message) = self._analyze_series_cmd.execute()

        self.assertEquals(AnalyzeSeriesCommand.STATUS_SUCCESS, status)
        self.assertEquals("", message)

        expected_mean = control_chart.mean()
        actual_mean = self._analyze_series_cmd._control_chart.mean()
        self.assertAlmostEquals(expected_mean, actual_mean, places=3)
コード例 #6
0
    def test_data_series_is_analyzed(self):
        tf = tempfile.NamedTemporaryFile()
        control_chart = ControlChart(SERIES_UNDER_CONTROL)

        test_input = ""
        for val in SERIES_UNDER_CONTROL:
            test_input += " {} \n".format(str(val))

        tf.write(test_input)
        tf.flush()

        sys.argv = ["analyze_series", tf.name, "--verbose"]

        (status, message) = self._analyze_series_cmd.execute()

        self.assertEquals(AnalyzeSeriesCommand.STATUS_SUCCESS, status)
        self.assertEquals("", message)

        expected_mean = control_chart.mean()
        actual_mean = self._analyze_series_cmd._control_chart.mean()
        self.assertAlmostEquals(expected_mean, actual_mean, places=3)