In-place location inferring

        See infer_location function

        Args:
        Returns:
            :obj:`Segment`: self
974851
def infer_location(
            self,
            location_query,
            max_distance,
            google_key,
            foursquare_client_id,
            foursquare_client_secret,
            limit
        ):
        

        self.location_from = infer_location(
            self.points[0],
            location_query,
            max_distance,
            google_key,
            foursquare_client_id,
            foursquare_client_secret,
            limit
        )
        self.location_to = infer_location(
            self.points[-1],
            location_query,
            max_distance,
            google_key,
            foursquare_client_id,
            foursquare_client_secret,
            limit
        )

        return self
525841
def get_bucket_location(self, bucket):
        
        details = self._details(
            method=b"GET",
            url_context=self._url_context(bucket=bucket, object_name="?location"),
        )
        d = self._submit(self._query_factory(details))
        d.addCallback(self._parse_bucket_location)
        return d
620173
def in_segmentlist(column, segmentlist):
    
    segmentlist = type(segmentlist)(segmentlist).coalesce()
    idx = column.argsort()
    contains = numpy.zeros(column.shape[0], dtype=bool)
    j = 0
    try:
        segstart, segend = segmentlist[j]
    except IndexError:  # no segments, return all False
        return contains
    i = 0
    while i < contains.shape[0]:
        # extract time for this index
        x = idx[i]  # <- index in original column
        time = column[x]
        # if before start, move to next value
        if time < segstart:
            i += 1
            continue
        # if after end, find the next segment and check value again
        if time >= segend:
            j += 1
            try:
                segstart, segend = segmentlist[j]
                continue
            except IndexError:
                break
        # otherwise value must be in this segment
        contains[x] = True
        i += 1
    return contains
9386
def locateChild(self, ctx, segments):
        
        result = self._getAppStoreResource(ctx, segments[0])
        if result is not None:
            child, segments = result, segments[1:]
            return child, segments

        if segments[0] == '':
            result = self.child_(ctx)
            if result is not None:
                child, segments = result, segments[1:]
                return child, segments

        # If the user is trying to access /private/*, then his session has
        # expired or he is otherwise not logged in. Redirect him to /login,
        # preserving the URL segments, rather than giving him an obscure 404.
        if segments[0] == 'private':
            u = URL.fromContext(ctx).click('/').child('login')
            for seg in segments:
                u = u.child(seg)
            return u, ()

        return rend.NotFound
578636
def find_all(self, pattern):
		
		pos = []
		last_found = -1
		while True:
			last_found = self.current_segment.data.find(pattern, last_found + 1)
			if last_found == -1:
				break
			pos.append(last_found + self.current_segment.start_address)
			
		return pos
1041931
def location_nearbystops(self, origin_coord_lat, origin_coord_long):
        
        response = self._request(
            '',
            originCoordLat=origin_coord_lat,
            originCoordLong=origin_coord_long)
        return _get_node(response, 'LocationList', 'StopLocation')
696179
def segment(self):
        
        if self._segment is None:
            self.assert_bind_client()
            if self.id is not None:
                self._segment = self.bind_client.get_segment(self.id)
        return self._segment
734148
def locateChild(self, ctx, segments):
        
        if self.fragment is not None:
            # There are still a bunch of bogus subclasses of this class, which
            # are used in a variety of distasteful ways.  'fragment' *should*
            # always be set to something that isn't None, but there's no way to
            # make sure that it will be for the moment.  Every effort should be
            # made to reduce public use of subclasses of this class (instead
            # preferring to wrap content objects with
            # IWebViewer.wrapModel()), so that the above check can be
            # removed. -glyph
            lc = getattr(self.fragment, 'locateChild', None)
            if lc is not None:
                x = lc(ctx, segments)
                if x is not NotFound:
                    return x
        return super(MantissaViewHelper, self).locateChild(ctx, segments)
1163993
function(segment) {
                return (this.start.eql(segment.start) && this.end.eql(segment.end)) ||
                    (this.start.eql(segment.end) && this.end.eql(segment.start));
              }
1341157
def infer(self, objectToInfer, stats=None):
    
    self.setLearning(False)
    self.sendReset()

    touches = None
    previousLocation = [None] * self.numColumns
    displacement = [0., 0.]
    features = objectToInfer["features"]
    objName = objectToInfer["name"]
    numOfFeatures = len(features)

    # Randomize touch sequences
    touchSequence = np.random.permutation(numOfFeatures)

    for sensation in xrange(self.numOfSensations):
      # Add sensation for all columns at once
      for col in xrange(self.numColumns):
        # Shift the touch sequence for each column
        colSequence = np.roll(touchSequence, col)
        feature = features[colSequence[sensation]]
        # Move the sensor to the center of the object
        locationOnObject = np.array([feature["top"] + feature["height"] / 2.,
                                     feature["left"] + feature["width"] / 2.])
        # Calculate displacement from previous location
        if previousLocation[col] is not None:
          displacement = locationOnObject - previousLocation[col]
        previousLocation[col] = locationOnObject

        # Sense feature at location
        self.motorInput[col].addDataToQueue(displacement)
        self.sensorInput[col].addDataToQueue(self.featureSDR[col][feature["name"]],
                                             False, 0)
      self.network.run(1)
      if self.debug:
        self._updateInferenceStats(statistics=stats, objectName=objName)

      if touches is None and self.isObjectClassified(objName, minOverlap=30):
        touches = sensation + 1
        if not self.debug:
          return touches

    return self.numOfSensations if touches is None else touches
742938
def locate(self):
        
        stored_location = self._get_stored_location()
        if not stored_location:
            ip_range = self._get_ip_range()
            stored_location = self._get_corresponding_location(ip_range)
        return stored_location
819021
def get_location(opts=None, provider=None):
    '''
    
    '''
    if opts is None:
        opts = {}
    ret = opts.get('location')
    if ret is None and provider is not None:
        ret = provider.get('location')
    if ret is None:
        ret = get_region_from_metadata()
    if ret is None:
        ret = DEFAULT_LOCATION
    return ret
855670
def location_lookup(self, req_location):
        
        location = False
        try:
            location = self.samecodes[req_location['code']]
        except Exception:
            pass
        try:
            location = self.lookup_samecode(req_location['local'], req_location['state'])
        except Exception:
            pass
        return location
421496
def get_location(dom, location):
    
    node = dom.documentElement
    for i in location:
        node = get_child(node, i)
        if not node:
            raise ValueError('Node at location %s does not exist.' % location) #TODO: line not covered
    return node
939198
def location(self):
        
        if self._location is None:
            self._location = "{}/{}-{}".format(
                self.stream,
                self.type,
                self.sequence,
            )
        return self._location
463383
def segment(self):
        
        if len(self.segment_list) == 1:
            return self.segment_list[0]
        else:
            err = "self.segment_list must only contain one segment to access"
            err += " the segment property. %s." %(str(self.segment_list),)
            raise TypeError(err)
878538
def location(self, tag=None, fromdate=None, todate=None):
        
        return self.call("GET", "/stats/outbound/clicks/location", tag=tag, fromdate=fromdate, todate=todate)