def __init__(self, stops): self.stops = stops self.source = stops[0].station self.destination = stops[-1].station self.departure = stops[0].departure_datetime() self.arrival = stops[-1].arrival_datetime() self.duration = hours(self.arrival - self.departure) self.distance = self.stops[-1].distance - self.stops[0].distance self.average_velocity = self.distance / self.duration self.train = stops[0].timetable.train self.timetable = stops[0].timetable
def average_velocity(self): return self.approximate_distance() / hours(self.duration())