Lynn Rees avatar Lynn Rees committed 077e30d Merge

Comments (0)

Files changed (5)

 644e1e9b7bb3b97c97b88bc93cc21838ea238800 0.1.2
 70eea3a4fa3d246967103378e7e3656e724f835c 0.1.3
 0ab3a064a9074bae9da780339a3273025afdb1d7 0.1.5
+1f153861563fd89025129ee9f3d2fcbb5fae10bd 0.1.6
 
 setup(
     name='twoq',
-    version='0.1.5',
+    version='0.1.7',
     description='iterator chaining, underscored by two-headed queues',
     long_description=open(os.path.join(os.getcwd(), 'README.rst'), 'r').read(),
     author='L. C. Rees',

twoq/mixins/reducing.py

 
     _omin = min
 
+    def minmax(self):
+        '''minimum and maximum values among incoming things'''
+        with self._sync as sync:
+            iterable = sync.iterable
+            sync(iter([min(iterable), max(iterable)]))
+        return self
+
+    _minmax = minmax
+
     def mode(self, _cnt=Counter):
         '''mode of incoming things'''
         with self._sync as sync:

twoq/tests/active/auto/mixins/reducing.py

             2,
         )
         
+    def test_minmax(self):
+        self.assertEquals(self.qclass(1, 2, 4).minmax().value(), [1, 4])
+        self.assertEquals(
+            self.qclass(10, 5, 100, 2, 1000).minmax().value(), [2, 1000],
+        )
+        
     def test_median(self):
         self.assertEquals(self.qclass(4, 5, 7, 2, 1).median().value(), 4)
         self.assertEquals(self.qclass(4, 5, 7, 2, 1, 8).median().value(), 4.5)

twoq/tests/active/man/mixins/reducing.py

         self.assertTrue(manq.balanced)
         self.assertEquals(manq.value(), 2)
         self.assertFalse(manq.balanced)
+        
+    def test_minmax(self):
+        manq = self.qclass(1, 2, 4).minmax()
+        self.assertFalse(manq.balanced)
+        manq.sync()
+        self.assertTrue(manq.balanced)
+        self.assertEquals(manq.value(), [1, 4])
+        self.assertFalse(manq.balanced)
+        manq = self.qclass(10, 5, 100, 2, 1000).minmax()
+        self.assertFalse(manq.balanced)
+        manq.sync()
+        self.assertTrue(manq.balanced)
+        self.assertEquals(manq.value(), [2, 1000])
+        self.assertFalse(manq.balanced)
 
     def test_sum(self):
         manq = self.qclass(1, 2, 3).sum()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.