Commits

Lynn Rees committed 57cc656 Merge

Comments (0)

Files changed (41)

 077e30db0ca77ed881e43684739997c3967de333 0.1.7
 29a7e0b4ec070a5f5b867cca052f6ad9fc67ead2 0.1.8
 ba26d0141298e981537411549697df5b445546a7 0.1.9
+7b99dca649401346836afbf0e8b063e84e09b09b 0.1.10
 
 setup(
     name='twoq',
-    version='0.1.9',
+    version='0.2.0',
     description='iterator chaining, underscored by two-headed queues',
     long_description=open(os.path.join(os.getcwd(), 'README.rst'), 'r').read(),
     author='L. C. Rees',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3.2',
         'Programming Language :: Python :: Implementation :: CPython',
-        'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Software Development :: Libraries',
         'Topic :: Utilities',
     ],
 
 __all__ = ('twoq', 'manq', 'autoq', 'port', 'syncq')
 
-__version__ = (0, 1, 9)
+__version__ = (0, 2, 0)

twoq/active/mixins.py

         '''
         incoming = self.incoming
         incoming.rotate(-index)
-        incoming.popleft()
         incoming.appendleft(value)
         incoming.rotate(index)
         return self
     _oreup = reup
 
     def shift(self):
-        '''shift incoming things to outgoing things'''
+        '''shift outgoing things to incoming things'''
         self._inextend(self.outgoing)
         return self
 
 
     def sync(self):
         '''
-        shift incoming things to outgoing things, clearing incoming things
+        shift outgoing things to incoming things, clearing incoming things
         '''
         # clear incoming items
         self._inclear()
     _osync = sync
 
     def outshift(self):
-        '''shift outgoing things to incoming things'''
+        '''shift incoming things to outgoing things'''
         # extend incoming items with outgoing items
         self._outextend(self.incoming)
         return self
 
     def outsync(self):
         '''
-        shift outgoing things to incoming things, clearing outgoing things
+        shift incoming things to outgoing things, clearing outgoing things
         '''
         # clear incoming items
         self._outclear()

twoq/lazy/__init__.py

+# -*- coding: utf-8 -*-
+'''lazy twoqs'''

twoq/lazy/contexts.py

+# -*- coding: utf-8 -*-
+'''twoq lazy contexts'''
+
+from itertools import tee
+
+__all__ = ('AutoContext', 'ManContext')
+
+
+class Context(object):
+
+    '''base context manager'''
+
+    def __init__(self, queue):
+        '''
+        init
+
+        @param queue: queue
+        '''
+        super(Context, self).__init__()
+        self._queue = queue
+
+    def __call__(self, args):
+        self._queue.outgoing = args
+
+    def iter(self, args):
+        self._queue.outgoing = iter(args)
+
+    def append(self, args):
+        self._queue.outgoing = iter([args])
+
+
+class ManContext(Context):
+
+    '''manual sync context manager'''
+
+    def __enter__(self):
+        # clear outgoing _queue
+        self._queue.outgoing = None
+        # extend scratch _queue with incoming things
+        self._queue._scratch, self._queue.incoming = tee(self._queue.incoming)
+        return self
+
+    def __exit__(self, t, v, e):
+        # clear scratch _queue
+        self._queue._scratch = None
+
+    @property
+    def iterable(self):
+        return self._queue._scratch
+
+
+class AutoContext(ManContext):
+
+    '''auto sync context manager'''
+
+    def __exit__(self, t, v, e):
+        # clear scratch _queue
+        self._queue._scratch = None
+        # extend incoming items with outgoing items
+        self._queue.incoming, self._queue.outgoing = tee(self._queue.outgoing)

twoq/lazy/filtering.py

+# -*- coding: utf-8 -*-
+'''twoq lazy filtering queues'''
+
+from inspect import ismodule
+
+from twoq.support import port
+from twoq.mixins.filtering import (
+    FilteringMixin, FilterMixin, CollectMixin, SetMixin, SliceMixin)
+
+from twoq.lazy.mixins import AutoQMixin, ManQMixin
+
+###############################################################################
+## lazy filter queues #######################################################
+###############################################################################
+
+
+class afilteringq(AutoQMixin, FilteringMixin):
+
+    '''auto-balanced filter queue'''
+
+
+class mfilteringq(ManQMixin, FilteringMixin):
+
+    '''manually balanced filter queue'''
+
+###############################################################################
+## lazy collecting queues ###################################################
+###############################################################################
+
+
+class acollectq(AutoQMixin, CollectMixin):
+
+    '''auto-balanced collecting queue'''
+
+collectq = acollectq
+
+
+class mcollectq(ManQMixin, CollectMixin):
+
+    '''manually balanced collecting queue'''
+
+###############################################################################
+## lazy set queues ##########################################################
+###############################################################################
+
+
+class asetq(AutoQMixin, SetMixin):
+
+    '''auto-balanced set queue'''
+
+setq = asetq
+
+
+class msetq(ManQMixin, SetMixin):
+
+    '''manually balanced set queue'''
+
+###############################################################################
+## lazy slice queues ########################################################
+###############################################################################
+
+
+class asliceq(AutoQMixin, SliceMixin):
+
+    '''auto-balanced slice queue'''
+
+sliceq = asliceq
+
+
+class msliceq(ManQMixin, SliceMixin):
+
+    '''manually balanced slice queue'''
+
+###############################################################################
+## lazy filter queues #######################################################
+###############################################################################
+
+
+class afilterq(AutoQMixin, FilterMixin):
+
+    '''auto-balanced filter queue'''
+
+filterq = afilterq
+
+
+class mfilterq(ManQMixin, FilterMixin):
+
+    '''manually balanced filtering queue'''
+
+__all__ = sorted(name for name, obj in port.items(locals()) if not any([
+    name.startswith('_'), ismodule(obj),
+]))

twoq/lazy/mapping.py

+# -*- coding: utf-8 -*-
+'''twoq lazy mapping queues'''
+
+from inspect import ismodule
+
+from twoq.support import port
+from twoq.mixins.mapping import (
+    DelayMixin, CopyMixin, MappingMixin, RepeatMixin, MapMixin)
+
+from twoq.lazy.mixins import AutoQMixin, ManQMixin
+
+###############################################################################
+## lazy delayed map queues ##################################################
+###############################################################################
+
+
+class adelayq(AutoQMixin, DelayMixin):
+
+    '''auto-balanced delayed map queue'''
+
+delayq = adelayq
+
+
+class mdelayq(ManQMixin, DelayMixin):
+
+    '''manually balanced delayed map queue'''
+
+###############################################################################
+## lazy copy queues #########################################################
+###############################################################################
+
+
+class acopyq(AutoQMixin, CopyMixin):
+
+    '''auto-balanced copy queue'''
+
+copyq = acopyq
+
+
+class mcopyq(ManQMixin, CopyMixin):
+
+    '''manually balanced copy queue'''
+
+###############################################################################
+## lazy map queues ##########################################################
+###############################################################################
+
+
+class amappingq(AutoQMixin, MappingMixin):
+
+    '''auto-balanced mapping queue'''
+
+mappingq = amappingq
+
+
+class mmappingq(ManQMixin, MappingMixin):
+
+    '''manually balanced mapping queue'''
+
+###############################################################################
+## lazy repeat queues #######################################################
+###############################################################################
+
+
+class arepeatq(AutoQMixin, RepeatMixin):
+
+    '''auto-balanced repeat queue'''
+
+repeatq = arepeatq
+
+
+class mrepeatq(ManQMixin, RepeatMixin):
+
+    '''manually balanced repeat queue'''
+
+###############################################################################
+## lazy mapping queues ######################################################
+###############################################################################
+
+
+class amapq(AutoQMixin, MapMixin):
+
+    '''auto-balanced map queue'''
+
+mapq = amapq
+
+
+class mmapq(ManQMixin, MapMixin):
+
+    '''manually balanced map queue'''
+
+__all__ = sorted(name for name, obj in port.items(locals()) if not any([
+    name.startswith('_'), ismodule(obj),
+]))

twoq/lazy/mixins.py

+# -*- coding: utf-8 -*-
+'''lazy twoq mixins'''
+
+from itertools import tee
+from collections import deque
+
+from stuf.utils import exhaust
+
+from twoq.mixins.queuing import QueueingMixin
+
+from twoq.lazy.contexts import AutoContext, ManContext
+
+__all__ = ['AutoQMixin', 'ManQMixin']
+
+
+class baseq(QueueingMixin):
+
+    '''base lazy queue'''
+
+    def __init__(self, *args):
+        # extend if just one argument
+        if len(args) == 1:
+            incoming = iter([args[0]])
+        else:
+            incoming = iter(args)
+        self._scratch = None
+        super(baseq, self).__init__(incoming, iter([]))
+
+    ###########################################################################
+    ## queue information ######################################################
+    ###########################################################################
+
+    def __contains__(self, value):
+        self.incoming, incoming = tee(self.incoming)
+        return value in list(incoming)
+
+    _oicontains = __contains__
+
+    def __len__(self):
+        self.incoming, incoming = tee(self.incoming)
+        return len(list(incoming))
+
+    count = _oicount = __len__
+
+    def outcount(self):
+        '''count of outgoing items'''
+        self.outgoing, outgoing = tee(self.outgoing)
+        return len(list(outgoing))
+
+    _ooutcount = outcount
+
+    @property
+    def balanced(self):
+        '''if queues are balanced'''
+        self.incoming, incoming = tee(self.incoming)
+        self.outgoing, outgoing = tee(self.outgoing)
+        return len(list(outgoing)) == len(list(incoming))
+
+    _obalanced = balanced
+
+    def index(self, thing):
+        '''
+        index of item in incoming things
+
+        @param thing: some thing
+        '''
+        self.incoming, incoming = tee(self.incoming)
+        return list(incoming).index(thing)
+
+    _oindex = index
+
+    def end(self, _l=list, _ln=len):
+        '''return outgoing things and clear'''
+        results = list(self.outgoing)
+        results = self.pop() if _ln(results) == 1 else _l(results)
+        self.clear()
+        return results
+
+    _ofinal = end
+
+    def results(self, _iterexcept=exhaust):
+        '''iterate over reversed outgoing things, clearing as it goes'''
+        return self.outgoing
+
+    _oresults = results
+
+    def value(self, _l=list, _ln=len):
+        '''return outgoing things and clear'''
+        results = list(self.outgoing)
+        results = results.pop() if _ln(results) == 1 else results
+        self.outclear()
+        return results
+
+    _ovalue = value
+
+    def first(self):
+        '''first thing among incoming things'''
+        with self._sync as sync:
+            sync.append(next(sync.iterable))
+        return self
+
+    _ofirst = first
+
+    def last(self):
+        '''last thing among incoming things'''
+        with self._sync as sync:
+            i1, _ = tee(sync.iterable)
+            sync.append(deque(i1, maxlen=1).pop())
+        return self
+
+    _olast = last
+
+    ###########################################################################
+    ## clear queues ###########################################################
+    ###########################################################################
+
+    def __delitem__(self, index):
+        self.incoming = list(self.incoming)
+        del self.incoming[index]
+        self.incoming = iter(self.incoming)
+
+    _oidelitem = __delitem__
+
+    def remove(self, thing):
+        '''
+        remove thing from incoming things
+
+        @param thing: some thing
+        '''
+        self.incoming = list(self.incoming)
+        self.incoming.remove(thing)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oiremove = remove
+
+    def clear(self):
+        '''clear all queues'''
+        self._call = None
+        self.outclear()
+        self.inclear()
+        return self
+
+    _oclear = clear
+
+    def inclear(self):
+        '''incoming things clear'''
+        self.incoming = iter([])
+        return self
+
+    _oiclear = inclear
+
+    def outclear(self):
+        '''incoming things clear'''
+        self.outgoing = iter([])
+        return self
+
+    _ooutclear = outclear
+
+    ###########################################################################
+    ## manipulate queues ######################################################
+    ###########################################################################
+
+    def append(self, thing):
+        '''incoming things right append'''
+        self.incoming = deque(self.incoming)
+        self.incoming.append(thing)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oappend = append
+
+    def appendleft(self, thing):
+        '''incoming things left append'''
+        self.incoming = deque(self.incoming)
+        self.incoming.appendleft(thing)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oappendleft = appendleft
+
+    def insert(self, index, value):
+        '''
+        insert thing into incoming things
+
+        @param index: index position
+        @param thing: some thing
+        '''
+        self.incoming = list(self.incoming)
+        self.incoming.insert(index, value)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oinsert = insert
+
+    def extend(self, things):
+        '''incoming things right extend'''
+        self.incoming = deque(self.incoming)
+        self.incoming.extend(things)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oextend = extend
+
+    def extendleft(self, things):
+        '''incoming things left extend'''
+        self.incoming = deque(self.incoming)
+        self.incoming.extendleft(things)
+        self.incoming = iter(self.incoming)
+        return self
+
+    _oextendleft = extendleft
+
+    ###########################################################################
+    ## balance queues #########################################################
+    ###########################################################################
+
+    def shift(self):
+        '''shift outgoing things to incoming things'''
+        self.outgoing, self.incoming = tee(self.outgoing)
+        return self
+
+    _oshift = _osync = sync = shift
+
+    _osync = sync
+
+    def outshift(self):
+        '''shift incoming things to outgoing things'''
+        self.outgoing, self.incoming = tee(self.incoming)
+        return self
+
+    _outshift = _outsync = outsync = outshift
+
+
+class AutoQMixin(baseq):
+
+    '''auto balancing manipulation queue mixin'''
+
+    def reup(self, _list=list):
+        '''put incoming things in incoming things as one incoming thing'''
+        with self._sync as _sync:
+            _sync.append(_list(self.incoming))
+        return self
+
+    _oreup = reup
+
+    @property
+    def _sync(self):
+        return AutoContext(self)
+
+
+class ManQMixin(baseq):
+
+    '''manually balanced manipulation queue mixin'''
+
+    @property
+    def _sync(self):
+        return ManContext(self)
+
+    def reup(self, _list=list):
+        '''put incoming things in incoming things as one incoming thing'''
+        return self

twoq/lazy/ordering.py

+# -*- coding: utf-8 -*-
+'''twoq lazy ordering queues'''
+
+from inspect import ismodule
+
+from twoq.support import port
+from twoq.mixins.ordering import OrderingMixin, RandomMixin, OrderMixin
+
+from twoq.lazy.mixins import AutoQMixin, ManQMixin
+
+###############################################################################
+## lazy ordering queues #####################################################
+###############################################################################
+
+
+class aorderingq(AutoQMixin, OrderingMixin):
+
+    '''auto-balanced ordering queue'''
+
+orderingq = aorderingq
+
+
+class morderingq(ManQMixin, OrderingMixin):
+
+    '''manually balanced ordering queue'''
+
+###############################################################################
+## lazy random queues #######################################################
+###############################################################################
+
+
+class arandomq(AutoQMixin, RandomMixin):
+
+    '''auto-balanced random queue'''
+
+randomq = arandomq
+
+
+class mrandomq(ManQMixin, RandomMixin):
+
+    '''manually balanced random queue'''
+
+###############################################################################
+## lazy order queues #####EEE################################################
+###############################################################################
+
+
+class aorderq(AutoQMixin, OrderMixin):
+
+    '''auto-balanced order queue'''
+
+orderq = aorderq
+
+
+class morderq(ManQMixin, OrderMixin):
+
+    '''manually balanced order queue'''
+
+__all__ = sorted(name for name, obj in port.items(locals()) if not any([
+    name.startswith('_'), ismodule(obj),
+]))
+del ismodule

twoq/lazy/queuing.py

+# -*- coding: utf-8 -*-
+'''twoq lazy queues'''
+
+from twoq.mixins.mapping import MapMixin
+from twoq.mixins.reducing import ReduceMixin
+from twoq.mixins.ordering import OrderMixin
+from twoq.mixins.filtering import FilterMixin
+
+from twoq.lazy.mixins import AutoQMixin, ManQMixin
+
+__all__ = ('autoq', 'manq', 'twoq')
+
+
+class autoq(AutoQMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
+
+    '''auto-balancing manipulation queue'''
+
+
+class manq(ManQMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
+
+    '''manually balanced manipulation queue'''
+
+
+twoq = autoq

twoq/lazy/reducing.py

+# -*- coding: utf-8 -*-
+'''twoq lazy reducing queues'''
+
+from inspect import ismodule
+
+from twoq.support import port
+from twoq.mixins.reducing import (
+    MathMixin, ReducingMixin, TruthMixin, ReduceMixin)
+
+from twoq.lazy.mixins import AutoQMixin, ManQMixin
+
+###############################################################################
+## lazy math queues ###########################################################
+###############################################################################
+
+
+class amathq(AutoQMixin, MathMixin):
+
+    '''auto-balancing math queue'''
+
+mathq = amathq
+
+
+class mmathq(ManQMixin, MathMixin):
+
+    '''manually balanced math queue'''
+
+###############################################################################
+## lazy reducing queues #######################################################
+###############################################################################
+
+
+class areducingq(AutoQMixin, ReducingMixin):
+
+    '''auto-balancing reducing queue'''
+
+reducingq = areducingq
+
+
+class mreducingq(ManQMixin, ReducingMixin):
+
+    '''manually balanced reducing queue'''
+
+###############################################################################
+## lazy truth queues ######E###################################################
+###############################################################################
+
+
+class atruthq(AutoQMixin, TruthMixin):
+
+    '''auto-balancing truth queue'''
+
+truthq = atruthq
+
+
+class mtruthq(ManQMixin, TruthMixin):
+
+    '''manually balanced truth queue'''
+
+
+###############################################################################
+## reduce queues ##############################################################
+###############################################################################
+
+
+class areduceq(AutoQMixin, ReduceMixin):
+
+    '''auto-balancing reduce queue'''
+
+reduceq = areduceq
+
+
+class mreduceq(ManQMixin, ReduceMixin):
+
+    '''manually balanced reduce queue'''
+
+__all__ = sorted(name for name, obj in port.items(locals()) if not any([
+    name.startswith('_'), ismodule(obj),
+]))
+del ismodule

twoq/mixins/filtering.py

         with self._sync as sync:
             call = self._call
             falsy, truey = _t(sync.iterable)
-            sync.append(list(_ff(call, falsy)))
-            sync.append(list(_filter(call, truey)))
+            sync(iter([list(_ff(call, falsy)), list(_filter(call, truey))]))
         return self
 
     _opartition = partition
     def initial(self, _islice=it.islice, _len=len):
         '''all incoming things except the last thing'''
         with self._sync as sync:
-            iterable = sync.iterable
-            sync(_islice(iterable, _len(iterable) - 1))
+            iterable1, iterable2 = it.tee(sync.iterable)
+            sync(_islice(iterable1, _len(list(iterable2)) - 1))
         return self
 
     _oinitial = initial
         @param n: number of things
         '''
         with self._sync as sync:
-            iterable = sync.iterable
-            sync(_islice(iterable, _len(iterable) - n, None))
+            iterable1, iterable2 = it.tee(sync.iterable)
+            sync(_islice(iterable1, _len(list(iterable2)) - n, None))
         return self
 
     _osnatch = snatch

twoq/mixins/mapping.py

         '''
         with self._sync as sync:
             if n is None:
-                sync(_starmap(self._call, _repeat(sync.iterable)))
+                sync(_starmap(self._call, _repeat(list(sync.iterable))))
             else:
-                sync(_starmap(self._call, _repeat(sync.iterable, n)))
+                sync(_starmap(self._call, _repeat(list(sync.iterable), n)))
         return self
 
     _otimes = times

twoq/mixins/ordering.py

     def reverse(self, _reversed=reversed):
         '''reverse incoming things'''
         with self._sync as sync:
-            sync(_reversed(sync.iterable))
+            sync(_reversed(list(sync.iterable)))
         return self
 
     _oreverse = reverse
     def choice(self, _choice=rm.choice):
         '''random choice from incoming things'''
         with self._sync as sync:
-            sync.append(_choice(sync.iterable))
+            sync.append(_choice(list(sync.iterable)))
         return self
 
     _ochoice = choice
     def shuffle(self, _shuffle=rm.shuffle):
         '''shuffle incoming things'''
         with self._sync as sync:
-            iterable = sync.iterable
+            iterable = list(sync.iterable)
             _shuffle(iterable)
             sync(iterable)
         return self

twoq/mixins/reducing.py

 
     @param iterable: an iterable
     '''
-    pending = len(iterable)
+    pending = len(it.tee(iterable, 1))
     nexts = c(p(n, _i(i)) for i in iterable)
     while pending:
         try:
     def average(self, _sum=isum, _truediv=op.truediv, _len=len):
         '''average of all incoming things'''
         with self._sync as sync:
-            iterable = sync.iterable
-            sync.append(_truediv(_sum(iterable, 0.0), _len(iterable)))
+            iterable1, iterable2 = it.tee(sync.iterable)
+            sync.append(_truediv(_sum(iterable1, 0.0), _len(list(iterable2))))
         return self
 
     _oaverage = average
     def minmax(self):
         '''minimum and maximum values among incoming things'''
         with self._sync as sync:
-            iterable = sync.iterable
-            sync(iter([min(iterable), max(iterable)]))
+            iterable1, iterable2 = it.tee(sync.iterable)
+            sync(iter([min(iterable1), max(iterable2)]))
         return self
 
     _minmax = minmax

twoq/tests/lazy/__init__.py

+# -*- coding: utf-8 -*-
+'''lazy queue tests'''

twoq/tests/lazy/auto/__init__.py

+# -*- coding: utf-8 -*-
+'''lazy automatic queues tests'''

twoq/tests/lazy/auto/test_autoq.py

+# -*- coding: utf-8 -*-
+'''autoq tests'''
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+from twoq.tests.mixins.auto.queuing import AQMixin
+from twoq.tests.mixins.auto.mapping import AMapQMixin
+from twoq.tests.mixins.auto.ordering import AOrderQMixin
+from twoq.tests.mixins.auto.reducing import AReduceQMixin
+from twoq.tests.mixins.auto.filtering import AFilterQMixin
+
+
+class TestAutoQ(
+    unittest.TestCase, AQMixin, AFilterQMixin, AMapQMixin, AReduceQMixin,
+    AOrderQMixin,
+):
+
+    def setUp(self):
+        from twoq.lazy.queuing import autoq
+        self.qclass = autoq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/auto/test_filtering.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.auto.filtering import *  # @UnusedWildImport
+from twoq.tests.mixins.auto.queuing import AQMixin
+
+
+class TestAutoFilterQ(unittest.TestCase, AQMixin, AFilterQMixin):
+
+    def setUp(self):
+        self.maxDiff = None
+        from twoq.lazy.filtering import afilterq
+        self.qclass = afilterq
+
+
+class TestAutoFilteringQ(unittest.TestCase, AQMixin, AFilteringQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import afilteringq
+        self.qclass = afilteringq
+
+
+class TestAutoSliceQ(unittest.TestCase, AQMixin, ASliceQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import asliceq
+        self.qclass = asliceq
+
+
+class TestAutoCollectQ(unittest.TestCase, AQMixin, ACollectQMixin):
+
+    def setUp(self):
+        self.maxDiff = None
+        from twoq.lazy.filtering import acollectq
+        self.qclass = acollectq
+
+
+class TestAutoSetQ(unittest.TestCase, AQMixin, ASetQMixin):
+
+    '''test automatically synchronized filtering'''
+
+    def setUp(self):
+        from twoq.lazy.filtering import asetq
+        self.qclass = asetq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/auto/test_mapping.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.auto.mapping import *  # @UnusedWildImport
+from twoq.tests.mixins.auto.queuing import AQMixin
+
+
+class TestAutoMap(AQMixin, AMapQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import amapq
+        self.qclass = amapq
+
+
+class TestAutoMappingQ(unittest.TestCase, AQMixin, AMappingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import amappingq
+        self.qclass = amappingq
+
+
+class TestAutoRepeatQ(unittest.TestCase, AQMixin, ARepeatQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import arepeatq
+        self.qclass = arepeatq
+
+
+class TestAutoDelayQ(unittest.TestCase, AQMixin, ADelayQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import adelayq
+        self.qclass = adelayq
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/auto/test_ordering.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.auto.ordering import *  # @UnusedWildImport
+from twoq.tests.mixins.auto.queuing import AQMixin
+
+
+class TestAutoOrderQ(unittest.TestCase, AQMixin, AOrderQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import aorderq
+        self.qclass = aorderq
+
+
+class TestAutoOrderingQ(unittest.TestCase, AQMixin, AOrderingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import aorderingq
+        self.qclass = aorderingq
+
+
+class TestAutoRandomQ(unittest.TestCase, AQMixin, ARandomQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import arandomq
+        self.qclass = arandomq
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/auto/test_reducing.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.auto.reducing import *  # @UnusedWildImport
+from twoq.tests.mixins.auto.queuing import AQMixin
+
+
+class TestAutoReduceQ(unittest.TestCase, AQMixin, AReduceQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import areduceq
+        self.qclass = areduceq
+
+
+class TestAutoReducingQ(unittest.TestCase, AQMixin, AReducingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import areducingq
+        self.qclass = areducingq
+
+
+class TestAutoMathQ(unittest.TestCase, AQMixin, AMathQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import amathq
+        self.qclass = amathq
+
+
+class TestAutoTruthQ(unittest.TestCase, AQMixin, ATruthQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import atruthq
+        self.qclass = atruthq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/man/__init__.py

+# -*- coding: utf-8 -*-
+'''lazy manual queues tests'''

twoq/tests/lazy/man/test_filtering.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.man.filtering import *  # @UnusedWildImport
+from twoq.tests.mixins.man.queuing import MQMixin
+
+
+class TestManFilterQ(unittest.TestCase, MFilterQMixin):
+
+    def setUp(self):
+        self.maxDiff = None
+        from twoq.lazy.filtering import mfilterq
+        self.qclass = mfilterq
+
+
+class TestManFilteringQ(unittest.TestCase, MQMixin, MFilteringQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import mfilteringq
+        self.qclass = mfilteringq
+
+
+class TestManSliceQ(unittest.TestCase, MQMixin, MSliceQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import msliceq
+        self.qclass = msliceq
+
+
+class TestManCollectQ(unittest.TestCase, MQMixin, MCollectQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import mcollectq
+        self.qclass = mcollectq
+
+
+class TestManSetQ(unittest.TestCase, MQMixin, MSetQMixin):
+
+    def setUp(self):
+        from twoq.lazy.filtering import msetq
+        self.qclass = msetq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/man/test_manq.py

+# -*- coding: utf-8 -*-
+'''manq tests'''
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+from twoq.tests.mixins.man.queuing import MQMixin
+from twoq.tests.mixins.man.mapping import MMapQMixin
+from twoq.tests.mixins.man.ordering import MOrderQMixin
+from twoq.tests.mixins.man.reducing import MReduceQMixin
+from twoq.tests.mixins.man.filtering import MFilterQMixin
+
+
+class TestManQ(
+    unittest.TestCase, MQMixin, MFilterQMixin, MMapQMixin, MReduceQMixin,
+    MOrderQMixin,
+):
+
+    def setUp(self):
+        from twoq.lazy.queuing import manq
+        self.qclass = manq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/man/test_mapping.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.man.mapping import *  # @UnusedWildImport
+from twoq.tests.mixins.man.queuing import MQMixin
+
+
+class TestManMap(unittest.TestCase, MQMixin, MMapQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import mmapq
+        self.qclass = mmapq
+
+
+class TestManMappingQ(unittest.TestCase, MQMixin, MMappingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import mmappingq
+        self.qclass = mmappingq
+
+
+class TestManRepeatQ(
+    unittest.TestCase, MQMixin, MRepeatQMixin
+):
+
+    def setUp(self):
+        from twoq.lazy.mapping import mrepeatq
+        self.qclass = mrepeatq
+
+
+class TestManDelayQ(unittest.TestCase, MQMixin, MDelayQMixin):
+
+    def setUp(self):
+        from twoq.lazy.mapping import mdelayq
+        self.qclass = mdelayq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/man/test_ordering.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.man.ordering import *  # @UnusedWildImport
+from twoq.tests.mixins.man.queuing import MQMixin
+
+
+class TestManOrderQ(unittest.TestCase, MQMixin, MOrderQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import morderq
+        self.qclass = morderq
+
+
+class TestManOrderingQ(unittest.TestCase, MQMixin, MOrderingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import morderingq
+        self.qclass = morderingq
+
+
+class TestManRandomQ(unittest.TestCase, MQMixin, MRandomQMixin):
+
+    def setUp(self):
+        from twoq.lazy.ordering import mrandomq
+        self.qclass = mrandomq
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/lazy/man/test_reducing.py

+# -*- coding: utf-8 -*-
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+#pylint: disable-msg=w0614,w0401
+from twoq.tests.mixins.man.reducing import *  # @UnusedWildImport
+from twoq.tests.mixins.man.queuing import MQMixin
+
+
+class TestManReduceQ(unittest.TestCase, MQMixin, MReduceQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import mreduceq
+        self.qclass = mreduceq
+
+
+class TestManReducingQ(unittest.TestCase, MQMixin, MReducingQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import mreducingq
+        self.qclass = mreducingq
+
+
+class TestManMathQ(unittest.TestCase, MQMixin, MMathQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import mmathq
+        self.qclass = mmathq
+
+
+class TestManTruthQ(unittest.TestCase, MQMixin, MTruthQMixin):
+
+    def setUp(self):
+        from twoq.lazy.reducing import mtruthq
+        self.qclass = mtruthq
+
+
+if __name__ == '__main__':
+    unittest.main()

twoq/tests/mixins/auto/__init__.py

File contents unchanged.

twoq/tests/mixins/auto/filtering.py

 
 
 class AFilterQMixin(AFilteringQMixin, ACollectQMixin, ASetQMixin, ASliceQMixin):
-    
+
     '''combination mixin'''
 
 __all__ = sorted(name for name, obj in port.items(locals()) if not any([

twoq/tests/mixins/auto/mapping.py

File contents unchanged.

twoq/tests/mixins/auto/ordering.py

File contents unchanged.

twoq/tests/mixins/auto/queuing.py

 
 
 class AQMixin(object):
+    ''
 
     ###########################################################################
     ## queue manipulation #####################################################
     def test_insert(self):
         q = self.qclass(1, 2, 3, 4, 5, 6)
         q.insert(2, 10)
-        self.assertEquals(q.outsync().value(), [1, 2, 10, 4, 5, 6])
+        self.assertEquals(q.outsync().value(), [1, 2, 10, 3, 4, 5, 6])
 
     def test_extend(self):
         self.assertEquals(
         self.assertEquals(autoq.value(), 'foo')
 
     def test_inclear(self):
-        self.assertEqual(len(self.qclass([1, 2, 5, 6]).inclear()), 0)
+        self.assertEqual(len(list(self.qclass([1, 2, 5, 6]).inclear())), 0)
 
     def test_outclear(self):
-        self.assertEqual(len(self.qclass([1, 2, 5, 6]).outclear().outgoing), 0)
+        self.assertEqual(
+            len(list(self.qclass([1, 2, 5, 6]).outclear().outgoing)), 0
+        )
 
     ###########################################################################
     ## queue balancing ########################################################
 
     def test_insync(self):
         q = self.qclass([1, 2, 3, 4, 5, 6]).outshift().inclear().shift()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_inshift(self):
         q = self.qclass([1, 2, 3, 4, 5, 6]).outshift().sync()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_outsync(self):
         q = self.qclass([1, 2, 3, 4, 5, 6]).outshift()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_outshift(self):
         q = self.qclass([1, 2, 3, 4, 5, 6]).outsync()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
-    ###########################################################################
-    ## queue information ######################################################
-    ###########################################################################
+    ##########################################################################
+    # queue information ######################################################
+    ##########################################################################
 
     def test_index(self):
         self.assertEquals(self.qclass(1, 2, 3, 4, 5, 6).index(3), 2)

twoq/tests/mixins/auto/reducing.py

File contents unchanged.

twoq/tests/mixins/man/__init__.py

File contents unchanged.

twoq/tests/mixins/man/filtering.py

File contents unchanged.

twoq/tests/mixins/man/mapping.py

File contents unchanged.

twoq/tests/mixins/man/ordering.py

File contents unchanged.

twoq/tests/mixins/man/queuing.py

     def test_insert(self):
         q = self.qclass(1, 2, 3, 4, 5, 6)
         q.insert(2, 10)
-        self.assertEquals(q.outsync().value(), [1, 2, 10, 4, 5, 6])
+        self.assertEquals(q.outsync().value(), [1, 2, 10, 3, 4, 5, 6])
 
     def test_extend(self):
         self.assertEquals(
         )
 
     def test_inclear(self):
-        self.assertEqual(len(self.qclass([1, 2, 5, 6]).inclear()), 0)
+        self.assertEqual(len(list(self.qclass([1, 2, 5, 6]).inclear())), 0)
 
     def test_outclear(self):
-        self.assertEqual(len(self.qclass([1, 2, 5, 6]).outclear().outgoing), 0)
+        self.assertEqual(
+            len(list(self.qclass([1, 2, 5, 6]).outclear().outgoing)), 0
+        )
 
     ###########################################################################
     ## queue balancing ########################################################
 
     def test_insync(self):
         q = self.qclass(1, 2, 3, 4, 5, 6).outshift().inclear().shift()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_inshift(self):
         q = self.qclass(1, 2, 3, 4, 5, 6).outshift().sync()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_outsync(self):
         q = self.qclass(1, 2, 3, 4, 5, 6).outshift()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     def test_outshift(self):
         q = self.qclass(1, 2, 3, 4, 5, 6).outsync()
-        self.assertSequenceEqual(q.incoming, q.outgoing)
+        self.assertEqual(list(q.incoming), list(q.outgoing))
 
     ###########################################################################
     ## queue information ######################################################

twoq/tests/mixins/man/reducing.py

File contents unchanged.