# Path: tde/util/functions.py
# def iterator_length(iterable):
# def unique(iterable):
# def unique_by(iterable, key):
# def intersection(iterable1, iterable2):
# def intersection_by(iterable1, iterable2, key):
# def grouper(n, iterable, padvalue=None):
# def fname2speaker(corpus_type):
# def fscore(p, r):


from collections import defaultdict
from tde.util.functions import flatten
import numpy as np
            bounds[fragment.name].append(fragment.interval)
            length += 1
        self.length = length
        self.bounds = {}
        for name, intervals in bounds.iteritems():
            points = set(flatten((interval.start, interval.end)
                                  for interval in intervals))
            self.bounds[name] = np.sort(np.array(list(points)))

    def __len__(self):
        return self.length

    def has_close(self, name, query_point):
        if not name in self.bounds:
            b = False
        else:
            points = self.bounds[name]
            ix = np.searchsorted(points, query_point, side='left')
            if ix == 0:
                found_point = points[0]
            elif ix == points.shape[0]:
                found_point = points[-1]
            elif query_point - points[ix-1] < points[ix] - query_point:
                found_point = points[ix-1]
            else:
                found_point = points[ix]
            b = np.abs(found_point - query_point) < self.threshold
        return b

    def __iter__(self):

# Path: tde/util/functions.py
# def iterator_length(iterable):
# def unique(iterable):
# def unique_by(iterable, key):
# def intersection(iterable1, iterable2):
# def intersection_by(iterable1, iterable2, key):
# def grouper(n, iterable, padvalue=None):
# def fname2speaker(corpus_type):
# def fscore(p, r):


# Path: tde/measures/boundaries.py
from collections import defaultdict
from tde.util.functions import flatten
import numpy as np

            bounds[fragment.name].append(fragment.interval)
            length += 1
        self.length = length
        self.bounds = {}
        for name, intervals in bounds.iteritems():
            points = set(flatten((interval.start, interval.end)
                                  for interval in intervals))
            self.bounds[name] = np.sort(np.array(list(points)))

    def __len__(self):
        return self.length

    def has_close(self, name, query_point):
        if not name in self.bounds:
            b = False
        else:
            points = self.bounds[name]
            ix = np.searchsorted(points, query_point, side='left')
            if ix == 0:
                found_point = points[0]
            elif ix == points.shape[0]:
                found_point = points[-1]
            elif query_point - points[ix-1] < points[ix] - query_point:
                found_point = points[ix-1]
            else:
                found_point = points[ix]
            b = np.abs(found_point - query_point) < self.threshold
        return b

    def __iter__(self):

        for name, points in self.bounds.iteritems():