Check for overlapped periods in the enrollments
177358
def __validate_enrollment_periods(self, enrollments):
        """"""

        for a, b in itertools.combinations(enrollments, 2):

            max_start = max(a.start, b.start)
            min_end = min(a.end, b.end)

            if max_start < min_end:
                msg = "invalid GrimoireLab enrollment dates. " \
                      "Organization dates overlap."
                raise InvalidFormatError(cause=msg)

        return enrollments
787952
def union_overlapping(intervals):
    """"""
    disjoint_intervals = []

    for interval in intervals:
        if disjoint_intervals and disjoint_intervals[-1].overlaps(interval):
            disjoint_intervals[-1] = disjoint_intervals[-1].union(interval)
        else:
            disjoint_intervals.append(interval)

    return disjoint_intervals
1128455
def get_overlaps(self) -> "IntervalList":
        
        overlaps = IntervalList()
        for i in range(len(self.intervals)):
            for j in range(i + 1, len(self.intervals)):
                first = self.intervals[i]
                second = self.intervals[j]
                ol = first.intersection(second)
                if ol is not None:
                    overlaps.add(ol)
        return overlaps
496115
public boolean overlaps(Interval<E> other)
  {
    if (other == null) return false;
    int comp12 = this.first.compareTo(other.second());
    int comp21 = this.second.compareTo(other.first());
    if (comp12 > 0 || comp21 < 0) {
      return false;
    } else {
      if (comp12 == 0) {
        if (!this.includesBegin() || !other.includesEnd()) {
          return false;
        }
      }
      if (comp21 == 0) {
        if (!this.includesEnd() || !other.includesBegin()) {
          return false;
        }
      }
      return true;
    }
  }
159186
def conflicts_with(self, section):
        ""
        for p in section.periods:
            t = (p.int_days, p.start, p.end)
            if t in self:
                return True
        return False
965966
def checkElementsOfTimeVaryAreLists(self):
        
        for param in self.time_vary:
            assert type(getattr(self,param))==list,param + ' is not a list, but should be' + \
                                                   ' because it is in time_vary'
325789
def check_overlap(pos, ins, thresh):
    
    ins_pos = ins[0]
    ins_len = ins[2]
    ol = overlap(ins_pos, pos)
    feat_len = pos[1] - pos[0] + 1
#    print float(ol) / float(feat_len)
    if float(ol) / float(feat_len) >= thresh:
        return True
    return False
1350790
def calculate_overlap(self1):
      """"""
      overs = []
      if not self1.tx_obj1.range.overlaps(self1.tx_obj2.range): return # if they dont overlap wont find anything
      for i in range(0,len(self1.tx_obj1.exons)):
        for j in range(0,len(self1.tx_obj2.exons)):
          osize = self1.tx_obj1.exons[i].range.overlap_size(self1.tx_obj2.exons[j].range)
          ofrac = 0
          if osize > 0:
            ofrac = min(float(osize)/float(self1.tx_obj1.exons[i].range.length)\
                       ,float(osize)/float(self1.tx_obj2.exons[j].range.length))

          if self1.tx_obj1.get_exon_count() == 1 or self1.tx_obj2.get_exon_count() == 1:
            # use single exon rules
            if osize >= self1.single_minover and ofrac >= self1.single_frac:
              #print 'single exon match'
              overs.append([i,j])
          else: # for multi exons
            if i == 0 or j == 0 or i == len(self1.tx_obj1.exons)-1 or j == len(self1.tx_obj2.exons)-1:
              #its on an end
              if osize >= self1.multi_minover and ofrac >= self1.multi_endfrac:
                #print 'end exon match'
                overs.append([i,j])
            #else its a middle
            elif osize >= self1.multi_minover and ofrac >= self1.multi_midfrac:
              #print 'mid exon match'
              overs.append([i,j])
      #print overs
      self1.overs = overs
578078
def display(self):
        """"""
        if self.degree and self.school:
            disp = self.degree + u' from ' + self.school
        else:
            disp = self.degree or self.school or None
        if disp is not None and self.date_range is not None:
            disp += u' (%d-%d)' % self.date_range.years_range
        return disp or u''
195307
def calculate_overlap(self):
      """"""
      overs = []
      if not self.tx_obj1.range.overlaps(self.tx_obj2.range): return [] # if they dont overlap wont find anything
      for i in range(0,len(self.j1)):
        for j in range(0,len(self.j2)):
          if self.j1[i].overlaps(self.j2[j],tolerance=self.tolerance):
            overs.append([i,j])
      return overs
460891
def _clashes(self, startTime, duration):
        
        return [m for m in self.activeMeasurements if m.overlapsWith(startTime, duration)]
1339214
def is_date_ranges_intersection(t1start, t1end, t2start, t2end):
    
    return (t1start <= t2start <= t1end) or (t2start <= t1start <= t2end)
1060827
def overlaps?(other)
      max_seconds = TimeOfDay::NUM_SECONDS_IN_DAY

      # Standard case, when Shifts are on the same day
      a, b = [self, other].map(&:range).sort_by(&:first)
      op = a.exclude_end? ? :> : :>=
      return true if a.last.send(op, b.first)

      # Special cases, when Shifts span to the next day
      return false if (a.last < max_seconds) && (b.last < max_seconds)

      a = Range.new(a.first, a.last - max_seconds, a.exclude_end?) if a.last > max_seconds
      b = Range.new(b.first, b.last - max_seconds, b.exclude_end?) if b.last > max_seconds
      a, b = [a, b].sort_by(&:last)
      b.last.send(op, a.last) && a.last.send(op, b.first)
    end
593964
def overlaps_with(self, othermatch, strict=False):
        '''
        
        '''
        one = self.matches_entry(othermatch, strict)
        if strict:
            return one
        return one and othermatch.matches_entry(self, strict)
1060070
def previous_occurrences(num, from)
      from = TimeUtil.match_zone(from, start_time) or raise ArgumentError, "Time required, got #{from.inspect}"
      return [] if from <= start_time
      a = enumerate_occurrences(start_time, from - 1).to_a
      a.size > num ? a[-1*num,a.size] : a
    end
560514
def get_enrollment_history_by_regid(regid,
                                    verbose='true',
                                    transcriptable_course='all',
                                    changed_since_date='',
                                    include_unfinished_pce_course_reg=False):
    
    return _json_to_enrollment_list(
        _enrollment_search(regid, verbose, transcriptable_course,
                           changed_since_date),
        include_unfinished_pce_course_reg)
275849
def overlaps(self, other):
        
        return (
            self.right > other.left and
            self.left < other.right and
            self.top < other.bottom and
            self.bottom > other.top
        )