Creates a segment from a GPX format.

        No preprocessing is done.

        Arguments:
            gpx_segment (:obj:`gpxpy.GPXTrackSegment`)
        Return:
            :obj:`Segment`
511952
def from_gpx(gpx_segment):
        
        points = []
        for point in gpx_segment.points:
            points.append(Point.from_gpx(point))
        return Segment(points)
18805
def _parse_qcd_segment(self, fptr):
        
        offset = fptr.tell() - 2

        read_buffer = fptr.read(3)
        length, sqcd = struct.unpack('>HB', read_buffer)
        spqcd = fptr.read(length - 3)

        return QCDsegment(sqcd, spqcd, length, offset)
1288577
def to_segmentlistdict(self):
		
		d = segments.segmentlistdict()
		for entry in self:
			d |= entry.segmentlistdict
		return d
435660
def segments(seg_type=None):
    

    for index in xrange(idaapi.get_segm_qty()):
        seg = Segment(index=index)
        if (seg_type is None) or (seg.type == seg_type):
            yield Segment(index=index)
1304236
def path_segment(self, index, value=None, default=None):
        
        if value is not None:
            segments = list(self.path_segments())
            segments[index] = unicode_quote_path_segment(value)
            new_path = '/' + '/'.join(segments)
            if self._tuple.path.endswith('/'):
                new_path += '/'
            return URL._mutate(self, path=new_path)
        try:
            return self.path_segments()[index]
        except IndexError:
            return default
630670
def from_cli(cls, opt, strain):
        
        return cls(strain, segment_length=opt.segment_length,
                   segment_start_pad=opt.segment_start_pad,
                   segment_end_pad=opt.segment_end_pad,
                   trigger_start=opt.trig_start_time,
                   trigger_end=opt.trig_end_time,
                   filter_inj_only=opt.filter_inj_only,
                   injection_window=opt.injection_window,
                   allow_zero_padding=opt.allow_zero_padding)
1235762
def load_segment(self, f, is_irom_segment=False):
        
        file_offs = f.tell()
        (offset, size) = struct.unpack('<II', f.read(8))
        self.warn_if_unusual_segment(offset, size, is_irom_segment)
        segment_data = f.read(size)
        if len(segment_data) < size:
            raise FatalError('End of file reading segment 0x%x, length %d (actual length %d)' % (offset, size, len(segment_data)))
        segment = ImageSegment(offset, segment_data, file_offs)
        self.segments.append(segment)
        return segment
567935
def postprocess_segments(self):
        """"""
        # make segs a list of mask arrays, it's easier to store
        # as there is a hdf5 equivalent
        for iseg, seg in enumerate(self.segs):
            mask = np.zeros(self._adata.shape[0], dtype=bool)
            mask[seg] = True
            self.segs[iseg] = mask
        # convert to arrays
        self.segs = np.array(self.segs)
        self.segs_tips = np.array(self.segs_tips)
961883
def segments(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.segments(index=self._name, **kwargs)
1280531
def segments_from_numpy(segments):
    """"""
    segments = segments if SEGMENTS_DIRECTION == 0 else segments.tranpose()
    segments = [map(int, s) for s in segments]
    return segments
671621
def _create_wx_app():
    
    wxapp = wx.GetApp()
    if wxapp is None:
        wxapp = wx.App(False)
        wxapp.SetExitOnFrameDelete(True)
        # retain a reference to the app object so it does not get garbage
        # collected and cause segmentation faults
        _create_wx_app.theWxApp = wxapp
539278
def removeSegment(self, segment, preserveCurve=False):
        
        if not isinstance(segment, int):
            segment = self.segments.index(segment)
        segment = normalizers.normalizeIndex(segment)
        if segment >= self._len__segments():
            raise ValueError("No segment located at index %d." % segment)
        preserveCurve = normalizers.normalizeBoolean(preserveCurve)
        self._removeSegment(segment, preserveCurve)
370133
def get_segment(self, segment_id):
        
        return model.Segment.deserialize(self.protocol.get('/segments/{id}',
                                         id=segment_id), bind_client=self)
1031358
def add_segments(self, segments):
        
        self.tracks.update([seg.track for seg in segments])
        self.segments.extend(segments)
141270
def _new_segment_data(self):
        """"""

        if self.data_type.nptype is not None:
            return np.zeros(self.number_values, dtype=self.data_type.nptype)
        else:
            return [None] * self.number_values
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)
488739
def createSegments(self, cells):
    
    segments = None

    for connections in self.connectionsBySource.itervalues():
      created = connections.createSegments(cells)

      if segments is None:
        segments = created
      else:
        # Sanity-check that the segment numbers are the same.
        np.testing.assert_equal(segments, created)

    return segments