Revision: 4989
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4989&view=rev
Author: mdboom
Date: 2008-02-25 12:27:51 -0800 (Mon, 25 Feb 2008)
Log Message:
---
Merged revisions 4947-4950,4952-4988 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
r4948 | jrevans | 2008-02-08 12:56:12 -0500 (Fri, 08 Feb 2008) | 2 lines
Removed a reference to nx, replaced with numpy.
r4977 | jdh2358 | 2008-02-19 10:26:56 -0500 (Tue, 19 Feb 2008) | 2 lines
added rec_groupby and rec2txt
r4987 | mdboom | 2008-02-25 15:21:39 -0500 (Mon, 25 Feb 2008) | 2 lines
[ 1901410 ] Newbie bug report: clip_on set to False actually True
Modified Paths:
--
trunk/matplotlib/examples/units/units_sample.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/mlab.py
Property Changed:
trunk/matplotlib/
Property changes on: trunk/matplotlib
___
Name: svnmerge-integrated
- /branches/v0_91_maint:1-4946,4951
+ /branches/v0_91_maint:1-4988
Modified: trunk/matplotlib/examples/units/units_sample.py
===
--- trunk/matplotlib/examples/units/units_sample.py 2008-02-25 20:24:33 UTC
(rev 4988)
+++ trunk/matplotlib/examples/units/units_sample.py 2008-02-25 20:27:51 UTC
(rev 4989)
@@ -8,9 +8,10 @@
"""
from basic_units import cm, inch
-from pylab import figure, show, nx
+from pylab import figure, show
+import numpy
-cms = cm *nx.arange(0, 10, 2)
+cms = cm *numpy.arange(0, 10, 2)
fig = figure()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-02-25 20:24:33 UTC (rev
4988)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-02-25 20:27:51 UTC (rev
4989)
@@ -2381,7 +2381,7 @@
#if t.get_clip_on(): t.set_clip_box(self.bbox)
-if kwargs.has_key('clip_on'): t.set_clip_path(self.axesPatch)
+if kwargs.has_key('clip_on'): t.set_clip_box(self.bbox)
return t
text.__doc__ = cbook.dedent(text.__doc__) % martist.kwdocd
@@ -4188,6 +4188,7 @@
Finally, marker can be (verts, 0), verts is a sequence of (x,y)
vertices for a custom scatter symbol.
+<<< .working
numsides is the number of sides
@@ -4201,6 +4202,9 @@
Finally, marker can be (verts, 0), verts is a sequence of (x,y)
vertices for a custom scatter symbol.
+===
+
+>>> .merge-right.r4987
s is a size argument in points squared.
Any or all of x, y, s, and c may be masked arrays, in which
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-02-25 20:24:33 UTC (rev
4988)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-02-25 20:27:51 UTC (rev
4989)
@@ -46,6 +46,7 @@
= record array helper functions =
* rec2txt : pretty print a record array
+ * rec2txt : pretty print a record array
* rec2csv : store record array in CSV file
* csv2rec : import record array from CSV file with type inspection
* rec_append_field : add a field/array to record array
@@ -2113,6 +2114,139 @@
return newrec.view(npy.recarray)
+def rec_groupby(r, groupby, stats):
+"""
+r is a numpy record array
+
+groupby is a sequence of record array attribute names that
+together form the grouping key. eg ('date', 'productcode')
+
+stats is a sequence of (attr, func, outname) which will call x =
+func(attr) and assign x to the record array output with attribute
+outname.
+Eg, stats = ( ('sales', len, 'numsales'), ('sales', npy.mean, 'avgsale') )
+
+return record array has dtype names for each attribute name in in
+the the 'groupby' argument, with the associated group values, and
+for each outname name in the stats argument, with the associated
+stat summary output
+"""
+# build a dictionary from groupby keys-> list of indices into r with
+# those keys
+rowd = dict()
+for i, row in enumerate(r):
+key = tuple([row[attr] for attr in groupby])
+rowd.setdefault(key, []).append(i)
+
+# sort the output by groupby keys
+keys = rowd.keys()
+keys.sort()
+
+rows = []
+for key in keys:
+row = list(key)
+# get the indices for this groupby key
+ind = rowd[key]
+thisr = r[ind]
+# call each stat function for this groupby slice
+row.extend([func(thisr[attr]) for attr, func, outname in stats])
+rows.append(row)
+
+# build the output record array with groupby and outname attributes
+attrs, funcs, outnames = zip(*stats)
+name