def compute_filtered_data(self, dump_config, dump_structure): all_trips = self.get_all_trips(dump_structure) moving_dump_file_name = dump_directory + dump_config.__key__( ) + "_move_trips.dat" try: mv_n_mv_temp_store = custom_pickle.load_obj(moving_dump_file_name) except FileNotFoundError: move_trips_pairs = [] non_move_trips_pairs = [] all_trips = sorted(all_trips, key=lambda _trip: _trip.start_s()) for trip_1 in all_trips: all_trips = sorted(all_trips, key=lambda _trip: _trip.start_s()) for trip_2 in all_trips: i = all_trips.index(trip_1) j = all_trips.index(trip_2) if j > i: if movable(trip_1, trip_2): move_trips_pairs.append((trip_1, trip_2)) else: non_move_trips_pairs.append((trip_1, trip_2)) mv_n_mv_temp_store = MoveNonMoveTempStore(move_trips_pairs, non_move_trips_pairs) custom_pickle.dump_obj(mv_n_mv_temp_store, moving_dump_file_name) return mv_n_mv_temp_store
def dump_data(self, dump_config, operating_trips=None): start = datetime.now() _filtered_trips = generate_random_dump_data_internal(self.info_enabled, dump_config, operating_trips, self.get_suffix()) self._make_dump_directory() dump_file_name = self.dump_directory + dump_config.__key__() + "_" + self.dump_prefix + ".dat" custom_pickle.dump_obj(_filtered_trips, dump_file_name) end = datetime.now() self.update_dump_log(dump_config, start, end) return True
def dump(self, file_name): custom_pickle.dump_obj(self, file_name)