Did I find the right examples for you? yes no

All Samples(18)  |  Call(16)  |  Derive(0)  |  Import(2)

src/c/o/cogent-1.5.3/tests/test_util/test_misc.py   cogent(Download)
from cogent.app.util import get_tmp_filename
from cogent.util.unit_test import TestCase, main
from cogent.util.misc import (iterable, max_index, min_index,
    flatten, is_iterable, is_char, is_char_or_noniterable,
    is_str_or_noniterable, not_list_tuple, list_flatten,
    def test_independent_spans(self):
        """get_independent_coords returns truly non-overlapping (decorated) spans"""
        # single span is returned
        data = [(0, 20, 'a')]
        got = get_independent_coords(data)
        self.assertEqual(got, data)
 
        # multiple non-overlapping
        data = [(20, 30, 'a'), (35, 40, 'b'), (65, 75, 'c')]
        got = get_independent_coords(data)
        # over-lapping first/second returns first occurrence by default
        data = [(20, 30, 'a'), (25, 40, 'b'), (65, 75, 'c')]
        got = get_independent_coords(data)
        self.assertEqual(got, [(20, 30, 'a'), (65, 75, 'c')])
        # but randomly the first or second if random_tie_breaker is chosen
        got = get_independent_coords(data, random_tie_breaker=True)

src/p/y/pycogent-HEAD/tests/test_util/test_misc.py   pycogent(Download)
from cogent.app.util import get_tmp_filename
from cogent.util.unit_test import TestCase, main
from cogent.util.misc import (iterable, max_index, min_index,
    flatten, is_iterable, is_char, is_char_or_noniterable,
    is_str_or_noniterable, not_list_tuple, list_flatten,
    def test_independent_spans(self):
        """get_independent_coords returns truly non-overlapping (decorated) spans"""
        # single span is returned
        data = [(0, 20, 'a')]
        got = get_independent_coords(data)
        self.assertEqual(got, data)
 
        # multiple non-overlapping
        data = [(20, 30, 'a'), (35, 40, 'b'), (65, 75, 'c')]
        got = get_independent_coords(data)
        # over-lapping first/second returns first occurrence by default
        data = [(20, 30, 'a'), (25, 40, 'b'), (65, 75, 'c')]
        got = get_independent_coords(data)
        self.assertEqual(got, [(20, 30, 'a'), (65, 75, 'c')])
        # but randomly the first or second if random_tie_breaker is chosen
        got = get_independent_coords(data, random_tie_breaker=True)