def test_can_compute_points_with_datetimes(self): two_days_ago = now() - timedelta(days=2) one_day_ago = now() - timedelta(days=1) today = now() line = Line.from_two_points(Point(two_days_ago, 1), Point(one_day_ago, 2)) expected = Point(today, 3) actual = line.point_from_x(today) self.assert_equals(expected.x, actual.x) self.assert_almost_equals(expected.y, actual.y, max_delta=0.1)
def test_can_compute_points_with_datetimes(self): two_days_ago = now() - timedelta(days=2) one_day_ago = now() - timedelta(days=1) today = now() line = Line.from_two_points(Point(two_days_ago, 1), Point(one_day_ago, 2)) expected = Point(today, 3) actual = line.point_from_x(today) self.assert_equals(expected.x, actual.x) self.assert_almost_equals(expected.y, actual.y, max_delta=0.1)
def calculate(self, actual_burndown, a_datetime): if len(actual_burndown) <= 1: return [] reference_burndown = self.find_reference_burndown(actual_burndown) current_burndown = actual_burndown[-1] reference_point = Point(reference_burndown.when, reference_burndown.remaining_time) current_point = Point(current_burndown.when, current_burndown.remaining_time) trend_line = Line.from_two_points(reference_point, current_point) final_value = trend_line.y_from_x(a_datetime) return [current_burndown, burndown_entry(a_datetime, final_value)]
def calculate(self, actual_burndown, a_datetime): if len(actual_burndown) <= 1: return [] reference_burndown = self.find_reference_burndown(actual_burndown) current_burndown = actual_burndown[-1] reference_point = Point(reference_burndown.when, reference_burndown.remaining_time) current_point = Point(current_burndown.when, current_burndown.remaining_time) trend_line = Line.from_two_points(reference_point, current_point) final_value = trend_line.y_from_x(a_datetime) return [current_burndown, burndown_entry(a_datetime, final_value)]
def test_can_compute_ys_when_points_have_datetimes_as_x(self): two_days_ago = now() - timedelta(days=2) one_day_ago = now() - timedelta(days=1) line = Line.from_two_points(Point(two_days_ago, 1), Point(one_day_ago, 2)) self.assert_almost_equals(3, line.y_from_x(now()), max_delta=0.1)
def test_can_instantiate_line_with_two_points(self): first = Point(1, 1) second = Point(21, 11) actual = Line.from_two_points(first, second) self.assert_equals(first, actual.point) self.assert_almost_equals(0.5, actual.slope, max_delta=0.001)
def test_can_compute_ys_when_points_have_datetimes_as_x(self): two_days_ago = now() - timedelta(days=2) one_day_ago = now() - timedelta(days=1) line = Line.from_two_points(Point(two_days_ago, 1), Point(one_day_ago, 2)) self.assert_almost_equals(3, line.y_from_x(now()), max_delta=0.1)
def test_can_instantiate_line_with_two_points(self): first = Point(1, 1) second = Point(21, 11) actual = Line.from_two_points(first, second) self.assert_equals(first, actual.point) self.assert_almost_equals(0.5, actual.slope, max_delta=0.001)