Revision: 7760
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7760&view=rev
Author:   sameerd
Date:     2009-09-14 19:32:27 +0000 (Mon, 14 Sep 2009)

Log Message:
-----------
added jointype == "inner" to mlab.recs_join

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/mlab.py

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2009-09-14 19:16:49 UTC (rev 
7759)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2009-09-14 19:32:27 UTC (rev 
7760)
@@ -1893,23 +1893,29 @@
 
     return newrec
 
-def recs_join(key, name, recs,missing=0.):
+def recs_join(key, name, recs, jointype='outer', missing=0.):
     """
-    Join a sequence of record arrays on key
+    Join a sequence of record arrays on single column key.
 
+    This function only joins a single column of the multiple record arrays
+
     *key*
       is the column name that acts as a key
 
     *name*
-      is the name that we want to join
+      is the name of the column that we want to join
 
+    *recs*
+      is a list of record arrays to join
+
+    *jointype*
+      is a string 'inner' or 'outer'
+
     *missing"
-      is what the missing fields are replaced by
+      is what any missing field is replaced by
 
-    *recarrays*
-      is a list of record arrays to join
 
-    returns a record array with columns [rowkey, name1, name2, ... namen]
+    returns a record array with columns [rowkey, name1, name2, ... namen].
 
     Example::
 
@@ -1917,12 +1923,21 @@
 
     """
     results = []
+    aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) 
for r in recs])
+
     def extract(r):
         if r is None: return missing
         else: return r[name]
 
-    for rowkey, row in cbook.align_iterators(operator.attrgetter(key), 
*[iter(r) for r in recs]):
-        results.append([rowkey] + map(extract, row))
+
+    if jointype == "outer":
+        for rowkey, row in aligned_iters:
+            results.append([rowkey] + map(extract, row))
+    elif jointype == "inner":
+        for rowkey, row in aligned_iters:
+            if None not in row: # throw out any Nones
+                results.append([rowkey] + map(extract, row))
+
     names = ",".join([key] + ["%s%d" % (name, d) for d in range(len(recs))])
     return np.rec.fromrecords(results, names=names)
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to