def test__Gets_the_story(self, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list) story = chart.getStory() correct_sentence_count = 7 result_sentence_count = story.body[2].sentence_count assert result_sentence_count == correct_sentence_count
def test__Calculates_dash_y_values(self, Chart, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list, mark='dash') story = chart.getStory() result_y = chart.getY() correct_y = np.array([3 / 9, 3 / 8, 3 / 7]) npt.assert_array_equal(result_y, correct_y)
def test__Calculates_semicolon_y_values(self, Chart, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list) story = chart.getStory() result_y = chart.getY() correct_y = np.array([2 / 9, 2 / 8, 2 / 7]) npt.assert_array_equal(result_y, correct_y)
def test__Calculates_dash_center_line(self, Chart, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list, mark='dash') story = chart.getStory() result_center_line = chart.getCenterLine() correct_center_line = 9 / 24 assert result_center_line == correct_center_line
def test__Gets_the_story_from_file(self, Story): from control_chart import Chart input_file_name = 'sample_text_body.txt' chart = Chart(filename=input_file_name) story = chart.getStory() correct_sentence_count = 7 result_sentence_count = story.body[2].sentence_count assert result_sentence_count == correct_sentence_count
def test__Calculates_dash_upper_control_limit(self, Chart, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list, mark='dash') story = chart.getStory() center_line = 9 / 24 # for dashes sentence_count = np.array([9, 8, 7]) result_upper_control_limit = chart.getUpperControlLimit() correct_upper_control_limit = center_line + 3 * np.sqrt( center_line * (1 - center_line) / sentence_count) npt.assert_array_equal(result_upper_control_limit, correct_upper_control_limit)
def test__Calculates_semicolon_lower_control_limit(self, Chart, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list) story = chart.getStory() center_line = 6 / 24 # for semicolons sentence_count = np.array([9, 8, 7]) result_lower_control_limit = chart.getLowerControlLimit() correct_lower_control_limit = center_line - 3 * np.sqrt( center_line * (1 - center_line) / sentence_count) correct_lower_control_limit = np.where(correct_lower_control_limit < 0, 0, correct_lower_control_limit) npt.assert_array_equal(result_lower_control_limit, correct_lower_control_limit)
def Chart(): from control_chart import Chart return Chart()
def test__Gets_dash_count_array(self, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list) result_array = chart.getDashCountArray() correct_array = np.array([3, 3, 3]) npt.assert_array_equal(result_array, correct_array)
def test__Gets_semicolon_count_array(self, Story, sample_story_body_list): from control_chart import Chart chart = Chart(sample_story_body_list) result_array = chart.getSemicolonCountArray() correct_array = np.array([2, 2, 2]) npt.assert_array_equal(result_array, correct_array)