Revision: 5850
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5850&view=rev
Author:   jdh2358
Date:     2008-07-24 21:56:06 +0000 (Thu, 24 Jul 2008)

Log Message:
-----------
minor cleanup of units example, added some to backend driver, more to be fixed

Modified Paths:
--------------
    trunk/matplotlib/examples/tests/backend_driver.py
    trunk/matplotlib/examples/units/artist_tests.py
    trunk/matplotlib/examples/units/bar_demo2.py
    trunk/matplotlib/examples/units/bar_unit_demo.py
    trunk/matplotlib/examples/units/basic_units.py
    trunk/matplotlib/examples/units/evans_test.py
    trunk/matplotlib/examples/units/evans_test2.py
    trunk/matplotlib/examples/units/radian_demo.py
    trunk/matplotlib/examples/units/units_scatter.py
    trunk/matplotlib/unit/memleak_hawaii3.py

Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py   2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/tests/backend_driver.py   2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -121,9 +121,23 @@
     'color_cycle.py',
 ]
 
+units_dir = os.path.join('..', 'units')
+units_files = [
+    'annotate_with_units.py',
+    #'artist_tests.py',  # broken, fixme
+    'bar_demo2.py',
+    #'bar_unit_demo.py', # broken, fixme
+    #'ellipse_with_units.py',  # broken, fixme
+    'radian_demo.py',
+    'units_sample.py',
+    #'units_scatter.py', # broken, fixme
 
+    ]
+
 files = [os.path.join(pylab_dir, fname) for fname in pylab_files] +\
-    [os.path.join(api_dir, fname) for fname in api_files]
+    [os.path.join(api_dir, fname) for fname in api_files] +\
+    [os.path.join(units_dir, fname) for fname in units_files]
+
 # tests known to fail on a given backend
 
 

Modified: trunk/matplotlib/examples/units/artist_tests.py
===================================================================
--- trunk/matplotlib/examples/units/artist_tests.py     2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/artist_tests.py     2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -14,9 +14,9 @@
 import matplotlib.units as units
 
 from basic_units import cm, inch
+import numpy as np
+from pylab import figure, show
 
-from pylab import figure, show, nx
-
 fig = figure()
 ax = fig.add_subplot(111)
 ax.xaxis.set_units(cm)
@@ -26,7 +26,7 @@
 verts = []
 for i in range(10):
     # a random line segment in inches
-    verts.append(zip(*inch*10*nx.mlab.rand(2, random.randint(2,15))))
+    verts.append(zip(*inch*10*np.random.rand(2, random.randint(2,15))))
 lc = collections.LineCollection(verts, axes=ax)
 ax.add_collection(lc)
 

Modified: trunk/matplotlib/examples/units/bar_demo2.py
===================================================================
--- trunk/matplotlib/examples/units/bar_demo2.py        2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/bar_demo2.py        2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -7,10 +7,11 @@
 units)
 
 """
+import numpy as np
 from basic_units import cm, inch
-from pylab import figure, show, nx
+from pylab import figure, show
 
-cms = cm *nx.arange(0, 10, 2)
+cms = cm *np.arange(0, 10, 2)
 bottom=0*cm
 width=0.8*cm
 

Modified: trunk/matplotlib/examples/units/bar_unit_demo.py
===================================================================
--- trunk/matplotlib/examples/units/bar_unit_demo.py    2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/bar_unit_demo.py    2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
+import numpy as np
 from basic_units import cm, inch
-from pylab import figure, show,nx
+from pylab import figure, show
 
 N = 5
 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm)
@@ -9,7 +10,7 @@
 fig = figure()
 ax = fig.add_subplot(111)
 
-ind = nx.arange(N)    # the x locations for the groups
+ind = np.arange(N)    # the x locations for the groups
 width = 0.35         # the width of the bars
 p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd)
 

Modified: trunk/matplotlib/examples/units/basic_units.py
===================================================================
--- trunk/matplotlib/examples/units/basic_units.py      2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/basic_units.py      2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -1,9 +1,8 @@
 import math
+import numpy as np
 
-
 import matplotlib.units as units
 import matplotlib.ticker as ticker
-import matplotlib.numerix as nx
 from matplotlib.axes import Axes
 from matplotlib.cbook import iterable
 
@@ -122,7 +121,7 @@
     self.proxy_target = self.value
 
   def get_compressed_copy(self, mask):
-    compressed_value = nx.ma.masked_array(self.value, mask=mask).compressed()
+    compressed_value = np.ma.masked_array(self.value, mask=mask).compressed()
     return TaggedValue(compressed_value, self.unit)
 
   def  __getattribute__(self, name):
@@ -135,9 +134,9 @@
 
   def __array__(self, t = None, context = None):
     if t is not None:
-      return nx.asarray(self.value).astype(t)
+      return np.asarray(self.value).astype(t)
     else:
-      return nx.asarray(self.value, 'O')
+      return np.asarray(self.value, 'O')
 
   def __array_wrap__(self, array, context):
     return TaggedValue(array, self.unit)
@@ -159,7 +158,7 @@
     return IteratorProxy(iter(self.value), self.unit)
 
   def get_compressed_copy(self, mask):
-    new_value = nx.ma.masked_array(self.value, mask=mask).compressed()
+    new_value = np.ma.masked_array(self.value, mask=mask).compressed()
     return TaggedValue(new_value, self.unit)
 
   def convert_to(self, unit):
@@ -211,7 +210,7 @@
     return TaggedValue(array, self)
 
   def __array__(self, t=None, context=None):
-    ret = nx.array([1])
+    ret = np.array([1])
     if t is not None:
       return ret.astype(t)
     else:
@@ -275,8 +274,8 @@
 
 radians = BasicUnit('rad', 'radians')
 degrees = BasicUnit('deg', 'degrees')
-radians.add_conversion_factor(degrees, 180.0/nx.pi)
-degrees.add_conversion_factor(radians, nx.pi/180.0)
+radians.add_conversion_factor(degrees, 180.0/np.pi)
+degrees.add_conversion_factor(radians, np.pi/180.0)
 
 secs = BasicUnit('s', 'seconds')
 hertz = BasicUnit('Hz', 'Hertz')
@@ -287,7 +286,7 @@
 
 # radians formatting
 def rad_fn(x,pos=None):
-  n = int((x / nx.pi) * 2.0 + 0.25)
+  n = int((x / np.pi) * 2.0 + 0.25)
   if n == 0:
     return '0'
   elif n == 1:
@@ -307,7 +306,7 @@
 
         if unit==radians:
             return units.AxisInfo(
-              majloc=ticker.MultipleLocator(base=nx.pi/2),
+              majloc=ticker.MultipleLocator(base=np.pi/2),
               majfmt=ticker.FuncFormatter(rad_fn),
               label=unit.fullname,
                 )

Modified: trunk/matplotlib/examples/units/evans_test.py
===================================================================
--- trunk/matplotlib/examples/units/evans_test.py       2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/evans_test.py       2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -11,7 +11,7 @@
 from matplotlib.cbook import iterable
 import matplotlib.units as units
 import matplotlib.ticker as ticker
-from pylab import figure, show, nx
+from pylab import figure, show
 
 class Foo:
     def __init__( self, val, unit=1.0 ):

Modified: trunk/matplotlib/examples/units/evans_test2.py
===================================================================
--- trunk/matplotlib/examples/units/evans_test2.py      2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/evans_test2.py      2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -3,13 +3,14 @@
 This example shows how the unit class can determine the tick locating,
 formatting and axis labeling.
 """
+import numpy as np
 from basic_units import radians, degrees, cos
-from pylab import figure, show, nx
+from pylab import figure, show
 from matplotlib.cbook import iterable
 import math
 
 
-x = nx.arange(0, 15, 0.01) * radians
+x = np.arange(0, 15, 0.01) * radians
 
 
 fig = figure()

Modified: trunk/matplotlib/examples/units/radian_demo.py
===================================================================
--- trunk/matplotlib/examples/units/radian_demo.py      2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/radian_demo.py      2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -1,7 +1,8 @@
+import numpy as np
 from basic_units import radians, degrees, cos
-from pylab import figure, show, nx
+from pylab import figure, show
 
-x = nx.arange(0, 15, 0.01) * radians
+x = np.arange(0, 15, 0.01) * radians
 
 fig = figure()
 fig.subplots_adjust(hspace=0.3)

Modified: trunk/matplotlib/examples/units/units_scatter.py
===================================================================
--- trunk/matplotlib/examples/units/units_scatter.py    2008-07-24 21:23:04 UTC 
(rev 5849)
+++ trunk/matplotlib/examples/units/units_scatter.py    2008-07-24 21:56:06 UTC 
(rev 5850)
@@ -8,14 +8,16 @@
 The example below shows support for unit conversions over masked
 arrays.
 """
+import numpy as np
 from basic_units import secs, hertz, minutes
-from matplotlib.pylab import figure, show, nx
+from matplotlib.pylab import figure, show
 
 # create masked array
 
-xsecs = secs*nx.ma.MaskedArray((1,2,3,4,5,6,7,8), nx.Float, 
mask=(1,0,1,0,0,0,1,0))
-#xsecs = secs*nx.arange(1,10.)
 
+xsecs = secs*np.ma.MaskedArray((1,2,3,4,5,6,7,8), (1,0,1,0,0,0,1,0), np.float)
+#xsecs = secs*np.arange(1,10.)
+
 fig = figure()
 ax1 = fig.add_subplot(3,1,1)
 ax1.scatter(xsecs, xsecs)

Modified: trunk/matplotlib/unit/memleak_hawaii3.py
===================================================================
--- trunk/matplotlib/unit/memleak_hawaii3.py    2008-07-24 21:23:04 UTC (rev 
5849)
+++ trunk/matplotlib/unit/memleak_hawaii3.py    2008-07-24 21:56:06 UTC (rev 
5850)
@@ -2,7 +2,7 @@
 
 import os, sys, time, gc
 import matplotlib
-matplotlib.use('PDF')
+matplotlib.use('Agg')
 
 from matplotlib.cbook import report_memory
 import numpy as np


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to