Analog of :func:`check_agency` for ``feed.trips``.
184316
def check_trips(
    feed: "Feed", *, as_df: bool = False, include_warnings: bool = False
) -> List:
    
    table = "trips"
    problems = []

    # Preliminary checks
    if feed.trips is None:
        problems.append(["error", "Missing table", table, []])
    else:
        f = feed.trips.copy()
        problems = check_for_required_columns(problems, table, f)
    if problems:
        return format_problems(problems, as_df=as_df)

    if include_warnings:
        problems = check_for_invalid_columns(problems, table, f)

    # Check trip_id
    problems = check_column_id(problems, table, f, "trip_id")

    # Check route_id
    problems = check_column_linked_id(
        problems, table, f, "route_id", feed.routes
    )

    # Check service_id
    g = pd.DataFrame()
    if feed.calendar is not None:
        g = pd.concat([g, feed.calendar], sort=False)
    if feed.calendar_dates is not None:
        g = pd.concat([g, feed.calendar_dates], sort=False)
    problems = check_column_linked_id(problems, table, f, "service_id", g)

    # Check direction_id
    v = lambda x: x in range(2)
    problems = check_column(
        problems, table, f, "direction_id", v, column_required=False
    )

    # Check block_id
    if "block_id" in f.columns:
        v = lambda x: pd.isnull(x) or valid_str(x)
        cond = ~f["block_id"].map(v)
        problems = check_table(problems, table, f, cond, "Blank block_id")

    # Check shape_id
    problems = check_column_linked_id(
        problems, table, f, "shape_id", feed.shapes, column_required=False
    )

    # Check wheelchair_accessible and bikes_allowed
    v = lambda x: x in range(3)
    for column in ["wheelchair_accessible", "bikes_allowed"]:
        problems = check_column(
            problems, table, f, column, v, column_required=False
        )

    # Check for trips with no stop times
    if include_warnings:
        s = feed.stop_times["trip_id"]
        cond = ~f["trip_id"].isin(s)
        problems = check_table(
            problems, table, f, cond, "Trip has no stop times", "warning"
        )

    return format_problems(problems, as_df=as_df)
477290
function(req, res, next){
    that.accessCheck(req, res, next, {forceHeaderCheck: true});
  }
551496
def specific_path_check(path, opt):
    """"""
    if opt.exclude:
        if path in opt.exclude:
            return False

    if opt.include:
        if path not in opt.include:
            return False

    return True
859379
def agent_checks(consul_url=None, token=None):
    '''
    

    '''
    ret = {}
    if not consul_url:
        consul_url = _get_config()
        if not consul_url:
            log.error('No Consul URL found.')
            ret['message'] = 'No Consul URL found.'
            ret['res'] = False
            return ret

    function = 'agent/checks'
    ret = _query(consul_url=consul_url,
                 function=function,
                 token=token,
                 method='GET')
    return ret
798807
def _checkAction(self, action, value):
        '''
        '''
        if action is None:
            raise WSActionException, 'Response missing WSAddress Action'
        if not value:
            raise WSActionException, 'missing WSAddress Action, expecting %s' %action
        if value != action:
            raise WSActionException, 'wrong WSAddress Action(%s), expecting %s'%(value,action)
867779
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]:
    """"""
    feed = load_raw_feed(path)
    return _trip_counts_by_date(feed)
26920
async def get_departures(
        self,
        station_id: str,
        direction_id: Optional[str] = None,
        max_journeys: int = 20,
        products: Optional[List[str]] = None,
    ) -> Dict[str, Any]:
        """"""
        self.station_id: str = station_id
        self.direction_id: str = direction_id

        self.max_journeys: int = max_journeys

        self.products_filter: str = _product_filter(products or ALL_PRODUCTS)

        base_url: str = _base_url()
        params: Dict[str, Union[str, int]] = {
            "selectDate": "today",
            "time": "now",
            "input": self.station_id,
            "maxJourneys": self.max_journeys,
            "boardType": "dep",
            "productsFilter": self.products_filter,
            "disableEquivs": "discard_nearby",
            "output": "xml",
            "start": "yes",
        }
        if self.direction_id:
            params["dirInput"] = self.direction_id

        url = base_url + urllib.parse.urlencode(params)

        try:
            with async_timeout.timeout(self._timeout):
                async with self._session.get(url) as response:
                    _LOGGER.debug(f"Response from RMV API: {response.status}")
                    xml = await response.read()
                    _LOGGER.debug(xml)
        except (asyncio.TimeoutError, aiohttp.ClientError):
            _LOGGER.error("Can not load data from RMV API")
            raise RMVtransportApiConnectionError()

        # pylint: disable=I1101
        try:
            self.obj = objectify.fromstring(xml)
        except (TypeError, etree.XMLSyntaxError):
            _LOGGER.debug(f"Get from string: {xml[:100]}")
            print(f"Get from string: {xml}")
            raise RMVtransportError()

        try:
            self.now = self.current_time()
            self.station = self._station()
        except (TypeError, AttributeError):
            _LOGGER.debug(
                f"Time/Station TypeError or AttributeError {objectify.dump(self.obj)}"
            )
            raise RMVtransportError()

        self.journeys.clear()
        try:
            for journey in self.obj.SBRes.JourneyList.Journey:
                self.journeys.append(RMVJourney(journey, self.now))
        except AttributeError:
            _LOGGER.debug(f"Extract journeys: {objectify.dump(self.obj.SBRes)}")
            raise RMVtransportError()

        return self.data()
383425
def get_checks(self, position=None):
        """"""
        if position is None:
            position = self.position
        return self.checkdefs[position][0]
580441
def run_checks(number_samples, k_choices):
        
        assert isinstance(k_choices, int), \
            "Number of optimal trajectories should be an integer"

        if k_choices < 2:
            raise ValueError(
                "The number of optimal trajectories must be set to 2 or more.")
        if k_choices >= number_samples:
            msg = "The number of optimal trajectories should be less than the \
                    number of samples"
            raise ValueError(msg)
472444
def parse_trips(self, xml, requested_time):
        
        obj = xmltodict.parse(xml)
        trips = []

        if 'error' in obj:
            print('Error in trips: ' + obj['error']['message'])
            return None

        try:
            for trip in obj['ReisMogelijkheden']['ReisMogelijkheid']:
                newtrip = Trip(trip, requested_time)
                trips.append(newtrip)
        except TypeError:
            # If no options are found, obj['ReisMogelijkheden'] is None
            return None

        return trips
1124760
def check_frequencies(
    feed: "Feed", *, as_df: bool = False, include_warnings: bool = False
) -> List:
    
    table = "frequencies"
    problems = []

    # Preliminary checks
    if feed.frequencies is None:
        return problems

    f = feed.frequencies.copy()
    problems = check_for_required_columns(problems, table, f)
    if problems:
        return format_problems(problems, as_df=as_df)

    if include_warnings:
        problems = check_for_invalid_columns(problems, table, f)

    # Check trip_id
    problems = check_column_linked_id(
        problems, table, f, "trip_id", feed.trips
    )

    # Check start_time and end_time
    time_cols = ["start_time", "end_time"]
    for col in time_cols:
        problems = check_column(problems, table, f, col, valid_time)

    for col in time_cols:
        f[col] = f[col].map(hp.timestr_to_seconds)

    # Start_time should be earlier than end_time
    cond = f["start_time"] >= f["end_time"]
    problems = check_table(
        problems, table, f, cond, "start_time not earlier than end_time"
    )

    # Headway periods should not overlap
    f = f.sort_values(["trip_id", "start_time"])
    for __, group in f.groupby("trip_id"):
        a = group["start_time"].values
        b = group["end_time"].values
        indices = np.flatnonzero(a[1:] < b[:-1]).tolist()
        if indices:
            problems.append(
                [
                    "error",
                    "Headway periods for the same trip overlap",
                    table,
                    indices,
                ]
            )

    # Check headway_secs
    v = lambda x: x >= 0
    problems = check_column(problems, table, f, "headway_secs", v)

    # Check exact_times
    v = lambda x: x in range(2)
    problems = check_column(
        problems, table, f, "exact_times", v, column_required=False
    )

    return format_problems(problems, as_df=as_df)
185989
function _info() {
    if ( LOG ) {
      let p = "";
      for ( let i = 0; i < segments.length * 2; i++ ) {
        p = p + " ";
      }

      let tripIds = [];
      for ( let i = 0; i < trips.length; i++ ) {
        tripIds.push(trips[i].id);
      }
      _log(p + "Trips From " + enter.name + ": " + trips.length + " ('" + tripIds.join("', '") + "')");

      _log(p + "   Segments: " + segments.length);
      _printSegments(segments, p + "   ");
    }
  }
638100
def trips(self, val):
        
        self._trips = val
        if val is not None and not val.empty:
            self._trips_i = self._trips.set_index("trip_id")
        else:
            self._trips_i = None
964368
function _tripGoesTo(trip, origin, destination) {
  let originFound = false;
  for ( let i = 0; i < trip.stopTimes.length; i++ ) {
    if ( !originFound && trip.stopTimes[i].stop.id === origin.id ) {
      originFound = true;
    }
    else if ( originFound ) {
      if ( trip.stopTimes[i].stop.id === destination.id ) {
        return true;
      }
    }
  }
  return false;
}
379737
def act(self, world_state, agent_host, current_r ):
        """"""
        
        obs_text = world_state.observations[-1].text
        obs = json.loads(obs_text) # most recent observation
        self.logger.debug(obs)
        if not u'XPos' in obs or not u'ZPos' in obs:
            self.logger.error("Incomplete observation received: %s" % obs_text)
            return 0
        current_s = "%d:%d" % (int(obs[u'XPos']), int(obs[u'ZPos']))
        self.logger.debug("State: %s (x = %.2f, z = %.2f)" % (current_s, float(obs[u'XPos']), float(obs[u'ZPos'])))
        if current_s not in self.q_table:
            self.q_table[current_s] = ([0] * len(self.actions))

        # update Q values
        if self.prev_s is not None and self.prev_a is not None:
            self.updateQTable( current_r, current_s )

        self.drawQ( curr_x = int(obs[u'XPos']), curr_y = int(obs[u'ZPos']) )

        # select the next action
        rnd = random.random()
        if rnd < self.epsilon:
            a = random.randint(0, len(self.actions) - 1)
            self.logger.info("Random action: %s" % self.actions[a])
        else:
            m = max(self.q_table[current_s])
            self.logger.debug("Current values: %s" % ",".join(str(x) for x in self.q_table[current_s]))
            l = list()
            for x in range(0, len(self.actions)):
                if self.q_table[current_s][x] == m:
                    l.append(x)
            y = random.randint(0, len(l)-1)
            a = l[y]
            self.logger.info("Taking q action: %s" % self.actions[a])

        # try to send the selected action, only update prev_s if this succeeds
        try:
            agent_host.sendCommand(self.actions[a])
            self.prev_s = current_s
            self.prev_a = a

        except RuntimeError as e:
            self.logger.error("Failed to send command: %s" % e)

        return current_r
670012
def trips(self):
    """"""
    trips = set()
    for route in self.routes():
      trips |= route.trips()
    return trips
811409
def loop_through_agency(self):
        """"""
        agency = self.agency
        with open(agency + '.txt') as f:
            data = eval(f.read())
        for table in data:
            for column in data[table]:
                value_link = data[table][column]
                data[table][column] = self.grab_definition(value_link)
        data = json.dumps(data)
        with open(agency + '_values.json', 'w') as f:
            f.write(str(data))