Inserts transportation modes of a track into a classifier

    Args:
        track (:obj:`Track`)
        clf (:obj:`Classifier`)
555066
def learn_transportation_mode(track, clf):
    
    for segment in track.segments:
        tmodes = segment.transportation_modes
        points = segment.points
        features = []
        labels = []

        for tmode in tmodes:
            points_part = points[tmode['from']:tmode['to']]
            if len(points_part) > 0:
                features.append(extract_features_2(points_part))
                labels.append(tmode['label'])

        clf.learn(features, labels)
1163892
function getItunesTracks(librarypath) {
    var libraryID;
    var trackObj = {};
    var isTrack = false;
    var line;
    var trackCount = 0;
    var streamIn;
    var streamOut = new stream_1.Readable;
    streamOut._read = function () { };
    streamIn = fs.createReadStream(librarypath);
    streamIn.on('error', function () { return streamOut.emit("error", 'The file you selected does not exist'); });
    streamIn = byline.createStream(streamIn);
    /*
    if (!module.exports.validPath(librarypath)) {
        streamOut.emit("error", 'Not a valid XML file')
    }
    */
    streamIn.on('readable', function () {
        while (null !== (line = streamIn.read())) {
            if (line.indexOf("<key>Library Persistent ID</key>") > -1) {
                /* ADD A KEY/VALUE PROPERTY */
                var iDString = String(line).match("<key>Library Persistent ID</key><string>(.*)</string>");
                libraryID = iDString[1];
            }
            else if (line.indexOf("<dict>") > -1) {
                /* START A NEW TRACK */
                trackObj = {};
                isTrack = true;
            }
            else if (line.indexOf("<key>") > -1) {
                /* ADD A PROPERTY TO THE TRACK */
                Object.assign(trackObj, module.exports.buildProperty(line));
            }
            else if (line.indexOf("</dict>") > -1) {
                /* END OF CURRENT TRACK */
                if (module.exports.objectIsMusicTrack(trackObj)) {
                    trackObj['Library Persistent ID'] = libraryID; //add extra metadata
                    trackCount++;
                    streamOut.push(JSON.stringify(trackObj));
                }
                isTrack = false;
            }
        }
    });
    streamIn.on('end', function () {
        if (trackCount == 0)
            streamOut.emit("error", 'No tracks exist in the file');
        trackCount = 0; //reset it
        streamOut.push(null);
    });
    streamIn.on('error', function (err) {
        streamOut.emit("error", 'Error parsing iTunes XML');
    });
    return streamOut;
}
974354
def _setDriftList(self, drift_length):
        
        if isinstance(drift_length, tuple) or isinstance(drift_length, list):
            if len(drift_length) == 1:
                self.dflist = drift_length * 3
            elif len(drift_length) == 2:
                self.dflist = []
                self.dflist.extend(drift_length)
                self.dflist.append(drift_length[0])
            elif len(drift_length) >= 3:
                self.dflist = drift_length[0:3]
                if self.dflist[0] != self.dflist[-1]:
                    print("warning: chicane is not symmetric.")
            else:
                print("drift_length is not a valid list or tuple.")
                self.mflag = False
        else:
            self.dflist = []
            self.dflist.extend([drift_length, drift_length, drift_length])
1270253
def do_track(self, arg):
        
        try:
            from rpython.translator.tool.reftracker import track
        except ImportError:
            print('** cannot import pypy.translator.tool.reftracker **',
                  file=self.stdout)
            return
        try:
            val = self._getval(arg)
        except:
            pass
        else:
            track(val)
173957
def infer_transportation_modes(self, dt_threshold=10):
        
        self.segments = [
            segment.infer_transportation_mode(dt_threshold=dt_threshold)
            for segment in self.segments
            ]
        return self
758063
def add_segment(self, segment):
        
        self.tracks.add(segment.track)
        self.segments.append(segment)
523845
def infer_transportation_mode(self, clf, min_time):
        
        self.transportation_modes = speed_clustering(clf, self.points, min_time)
        return self
1170427
def add_tracks(self, track):
        
        from trackhub import BaseTrack
        if isinstance(track, BaseTrack):
            self.add_child(track)
            self._tracks.append(track)
        else:
            for t in track:
                self.add_child(t)
                self._tracks.append(t)
48317
def addTransceiver(self, trackOrKind, direction='sendrecv'):
        
        self.__assertNotClosed()

        # determine track or kind
        if hasattr(trackOrKind, 'kind'):
            kind = trackOrKind.kind
            track = trackOrKind
        else:
            kind = trackOrKind
            track = None
        if kind not in ['audio', 'video']:
            raise InternalError('Invalid track kind "%s"' % kind)

        # check direction
        if direction not in sdp.DIRECTIONS:
            raise InternalError('Invalid direction "%s"' % direction)

        # don't add track twice
        if track:
            self.__assertTrackHasNoSender(track)

        return self.__createTransceiver(
            direction=direction,
            kind=kind,
            sender_track=track)
795214
def log_track_update(log_track):
    
    log_track[LOG_TRACK_COUNT] += 1
    if log_track[LOG_TRACK_COUNT] < log_track[LOG_TRACK_THRESHOLD]:
        return False
    log_track[LOG_TRACK_COUNT] = 0
    return True
393528
def link_to_trackable(object, object_type)
      model_name = object_type.downcase

      if object
        link_to(model_name, edit_path(:model_name => model_name.pluralize, :id => object.id))
      else
        "a #{model_name} which does not exist anymore"
      end
    end
10369
def _parse_track_id(self,sdp):
        ''''''
        m = re.search(r'a=control:(?P<trackid>[\w=\d]+)',sdp,re.S)
        return (m and m.group('trackid')) or ''
461895
def relocate_audio_to_single_container(self, target_path):
        

        cont = containers.AudioContainer(target_path)
        cont.open()

        new_tracks = {}

        # First create a new container track for all existing tracks
        for track in self.tracks.values():
            sr = track.sampling_rate
            samples = track.read_samples()

            cont.set(track.idx, samples, sr)
            new_track = tracks.ContainerTrack(track.idx, cont)

            new_tracks[track.idx] = new_track

        # Update track list of corpus
        self._tracks = new_tracks

        # Update utterances to point to new tracks
        for utterance in self.utterances.values():
            new_track = self.tracks[utterance.track.idx]
            utterance.track = new_track

        cont.close()
542446
def trajectory_set_item(self, idx, value):
    
    import mdtraj
    assert isinstance(self, mdtraj.Trajectory), type(self)
    if not isinstance(value, mdtraj.Trajectory):
        raise TypeError("value to assign is of incorrect type(%s). Should be mdtraj.Trajectory" % type(value))
    idx = np.index_exp[idx]
    frames, atoms = None, None
    if isinstance(idx, (list, tuple)):
        if len(idx) == 1:
            frames, atoms = idx[0], slice(None, None, None)
        if len(idx) == 2:
            frames, atoms = idx[0], idx[1]
        if len(idx) >= 3 or len(idx) == 0:
            raise IndexError("invalid slice by %s" % idx)

    self.xyz[frames, atoms] = value.xyz
    self._time[frames] = value.time
    self.unitcell_lengths[frames] = value.unitcell_lengths
    self.unitcell_angles[frames] = value.unitcell_angles
887051
public void spawnTracksFromDetected() {
		// mark detected features with no matches as available
		FastQueue<AssociatedIndex> matches = associate.getMatches();

		int N = detector.getNumberOfFeatures();
		for( int i = 0; i < N; i++ )
			associated[i] = false;

		for( AssociatedIndex i : matches.toList() ) {
			associated[i.dst] = true;
		}

		// spawn new tracks for unassociated detected features
		for( int i = 0; i < N; i++ ) {
			if( associated[i])
				continue;

			Point2D_F64 p = detector.getLocation(i);

			TD d = detectedDesc.get(i);

			CombinedTrack<TD> track;

			if( tracksUnused.size() > 0 ) {
				track = tracksUnused.pop();
			} else {
				track = new CombinedTrack<>();
				track.desc = detector.createDescription();
				track.track = trackerKlt.createNewTrack();
			}

			// create the descriptor for tracking
			trackerKlt.setDescription((float)p.x,(float)p.y,track.track);
			// set track ID and location
			track.featureId = totalTracks++;
			track.desc.setTo(d);
			track.set(p);

			// update list of active tracks
			tracksPureKlt.add(track);
			tracksSpawned.add(track);
		}
	}
943992
def match_tracks(self, model_tracks, obs_tracks, unique_matches=True, closest_matches=False):
        
        if unique_matches:
            pairings = self.track_matcher.match_tracks(model_tracks, obs_tracks, closest_matches=closest_matches)
        else:
            pairings = self.track_matcher.neighbor_matches(model_tracks, obs_tracks)
        return pairings
1178656
def get_track_info(track_id):
    
    logger.info('Retrieving more info on the track')
    info_url = url["trackinfo"].format(track_id)
    r = requests.get(info_url, params={'client_id': CLIENT_ID}, stream=True)
    item = r.json()
    logger.debug(item)
    return item