How to use the fileseq.FrameSet.from_iterable function in Fileseq

To help you get started, we’ve selected a few Fileseq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___xor__(self, test, expect):
        """
        Harness to test if the FrameSet.__xor__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = f ^ t
        e = FrameSet.from_iterable(set(expect) ^ set(v), sort=True)
        m = u'FrameSet("{0}") ^ FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(f, t, e))
        m = u'FrameSet("{0}") ^ FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(test, t, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___rsub__(self, test, expect):
        """
        Harness to test if the FrameSet.__rsub__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = t - f
        e = FrameSet.from_iterable(set(v) - set(expect), sort=True)
        m = u'FrameSet("{0}") - FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(t, f, e))
        m = u'FrameSet("{0}") - FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(t, test, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___rand__(self, test, expect):
        """
        Harness to test if the FrameSet.__rand__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = t & f
        e = FrameSet.from_iterable(set(v) & set(expect), sort=True)
        m = u'FrameSet("{0}") & FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(t, f, e))
        m = u'FrameSet("{0}") & FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(t, test, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check_intersection(self, test, expect):
        """
        Harness to test if the FrameSet.intersection call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        # the intersection of the empty FrameSet with any other is always the empty FrameSet
        if not test and not expect:
            self.assertEqual(f.intersection(FrameSet('1')), f)
            self.assertEqual(f.intersection(FrameSet('-1')), f)
            self.assertEqual(f.intersection(expect), f)
            return
        for v in [[expect[0]], expect, expect + [max(expect)+1], [i + max(expect) + 1 for i in expect]]:
            t = FrameSet.from_iterable(v)
            r = f.intersection(t)
            e = FrameSet.from_iterable(set(expect).intersection(v), sort=True)
            m = u'FrameSet("{0}").intersection(FrameSet("{1}")) != {2}'
            self.assertEqual(r, e, m.format(t, f, e))
            m = u'FrameSet("{0}").intersection(FrameSet("{1}")) returns {2}: got {3}'
            self.assertIsInstance(r, FrameSet, m.format(test, t, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___rand__(self, test, expect):
        """
        Harness to test if the FrameSet.__rand__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = t & f
        e = FrameSet.from_iterable(set(v) & set(expect), sort=True)
        m = u'FrameSet("{0}") & FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(t, f, e))
        m = u'FrameSet("{0}") & FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(t, test, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___xor__(self, test, expect):
        """
        Harness to test if the FrameSet.__xor__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = f ^ t
        e = FrameSet.from_iterable(set(expect) ^ set(v), sort=True)
        m = u'FrameSet("{0}") ^ FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(f, t, e))
        m = u'FrameSet("{0}") ^ FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(test, t, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___and__(self, test, expect):
        """
        Harness to test if the FrameSet.__and__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        v = [i + max(expect) + 1 for i in expect] or list(range(999, 1999))
        t = FrameSet.from_iterable(v)
        r = f & t
        e = FrameSet.from_iterable(set(expect) & set(v), sort=True)
        m = u'FrameSet("{0}") & FrameSet("{1}") != FrameSet("{2}")'
        self.assertEqual(r, e, m.format(f, t, e))
        m = u'FrameSet("{0}") & FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(r, FrameSet, m.format(test, t, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
Harness to test if the FrameSet.intersection call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        # the intersection of the empty FrameSet with any other is always the empty FrameSet
        if not test and not expect:
            self.assertEqual(f.intersection(FrameSet('1')), f)
            self.assertEqual(f.intersection(FrameSet('-1')), f)
            self.assertEqual(f.intersection(expect), f)
            return
        for v in [[expect[0]], expect, expect + [max(expect)+1], [i + max(expect) + 1 for i in expect]]:
            t = FrameSet.from_iterable(v)
            r = f.intersection(t)
            e = FrameSet.from_iterable(set(expect).intersection(v), sort=True)
            m = u'FrameSet("{0}").intersection(FrameSet("{1}")) != {2}'
            self.assertEqual(r, e, m.format(t, f, e))
            m = u'FrameSet("{0}").intersection(FrameSet("{1}")) returns {2}: got {3}'
            self.assertIsInstance(r, FrameSet, m.format(test, t, FrameSet, type(r)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
"""
        Harness to test if the FrameSet.__ge__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        # the empty FrameSet is greater than nothing, except for itself
        if not test and not expect:
            self.assertFalse(f >= FrameSet('1'))
            self.assertFalse(f >= FrameSet('-1'))
            self.assertTrue(f >= expect)
            return
        for i in [expect, expect[:-1]]:
            try:
                r = FrameSet.from_iterable(i)
            except ParseException:
                # this will happen if len(expect) == 1
                continue
            should_succeed = f >= r
            m = u'FrameSet("{0}") >= FrameSet("{1}"'
            self.assertTrue(should_succeed, m.format(test, r))
            m = u'FrameSet("{0}") >= FrameSet("{1}") returns {2}: got {3}'
            self.assertIsInstance(should_succeed, bool, m.format(test, r, bool, type(should_succeed)))
github justinfx / fileseq / test / test_fuzz.py View on Github external
def _check___lt__(self, test, expect):
        """
        Harness to test if the FrameSet.__lt__ call works properly.
        :param test: the string to pass to FrameSet
        :param expect: the expected list of values that FrameSet will hold
        :return: None
        """
        f = FrameSet(test)
        # the empty FrameSet is less than everything, except for itself
        if not test and not expect:
            self.assertTrue(f < FrameSet('1'))
            self.assertTrue(f < FrameSet('-1'))
            self.assertFalse(f < expect)
            return
        r = FrameSet.from_iterable(expect + [max(expect) + 1])
        should_succeed = f < r
        should_fail = r < f
        m = u'FrameSet("{0}") < FrameSet("{1}")'
        self.assertTrue(should_succeed, m.format(test, r))
        self.assertFalse(should_fail, m.format(r, test))
        m = u'FrameSet("{0}") < FrameSet("{1}") returns {2}: got {3}'
        self.assertIsInstance(should_succeed, bool, m.format(test, r, bool, type(should_succeed)))
        self.assertIsInstance(should_fail, bool, m.format(r, test, bool, type(should_fail)))