parameters: (self, journey)
return_statement: return True
docstring: We filter the journeys that use an "heavy" mode as fallback for a short time.
          Typically you don't take your car for only 2 minutes.
          Heavy fallback modes are Bike and Car, BSS is not considered as one.
          We also filter too short direct path except for Bike
docstring_summary: We filter the journeys that use an "heavy" mode as fallback for a short time.
          Typically you don't take your car for only 2 minutes.
          Heavy fallback modes are Bike and Car, BSS is not considered as one.
          We also filter too short direct path except for Bike
docstring_tokens: We filter the journeys that use an heavy mode as fallback for a short time . Typically you don t take your car for only 2 minutes . Heavy fallback modes are Bike and Car BSS is not considered as one . We also filter too short direct path except for Bike
function: def filter_func(self, journey):
          """
          We filter the journeys that use an "heavy" mode as fallback for a short time.
          Typically you don't take your car for only 2 minutes.
          Heavy fallback modes are Bike and Car, BSS is not considered as one.
          We also filter too short direct path except for Bike
          """
  
          def _exceed_min_duration(min_duration, total_duration):
              return total_duration < min_duration
  
          def _is_bike_direct_path(journey):
              return len(journey.sections) == 1 and journey.sections[0].street_network.mode == response_pb2.Bike
  
          # We do not filter direct_path bike journeys
          if _is_bike_direct_path(journey=journey):
              return True
  
          on_bss = False
          for s in journey.sections:
              if s.type == response_pb2.BSS_RENT:
                  on_bss = True
              elif s.type == response_pb2.BSS_PUT_BACK:
                  on_bss = False
              elif s.type != response_pb2.STREET_NETWORK:
                  continue
  
              min_mode = None
              total_duration = 0
              if s.street_network.mode == response_pb2.Car:
                  min_mode = self.min_car
                  total_duration = journey.durations.car
              elif s.street_network.mode == response_pb2.Taxi:
                  min_mode = self.min_taxi
                  total_duration = journey.durations.taxi
              elif s.street_network.mode == response_pb2.Ridesharing:
                  min_mode = self.min_ridesharing
                  total_duration = journey.durations.ridesharing
              elif s.street_network.mode == response_pb2.Bike:
                  min_mode = self.min_bike
                  total_duration = journey.durations.bike
              else:
                  continue
  
              if (
                  not on_bss
                  and min_mode is not None
                  and _exceed_min_duration(min_duration=min_mode, total_duration=total_duration)
              ):
                  return False
  
          return True
function_tokens: def filter_func ( self , journey ) : def _exceed_min_duration ( min_duration , total_duration ) : return total_duration < min_duration def _is_bike_direct_path ( journey ) : return len ( journey . sections ) == 1 and journey . sections [ 0 ] . street_network . mode == response_pb2 . Bike # We do not filter direct_path bike journeys if _is_bike_direct_path ( journey = journey ) : return True on_bss = False for s in journey . sections : if s . type == response_pb2 . BSS_RENT : on_bss = True elif s . type == response_pb2 . BSS_PUT_BACK : on_bss = False elif s . type != response_pb2 . STREET_NETWORK : continue min_mode = None total_duration = 0 if s . street_network . mode == response_pb2 . Car : min_mode = self . min_car total_duration = journey . durations . car elif s . street_network . mode == response_pb2 . Taxi : min_mode = self . min_taxi total_duration = journey . durations . taxi elif s . street_network . mode == response_pb2 . Ridesharing : min_mode = self . min_ridesharing total_duration = journey . durations . ridesharing elif s . street_network . mode == response_pb2 . Bike : min_mode = self . min_bike total_duration = journey . durations . bike else : continue if ( not on_bss and min_mode is not None and _exceed_min_duration ( min_duration = min_mode , total_duration = total_duration ) ) : return False return True