Revision: 8499
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8499&view=rev
Author:   jdh2358
Date:     2010-07-06 01:24:58 +0000 (Tue, 06 Jul 2010)

Log Message:
-----------
fix some code that breaks python 2.4

Modified Paths:
--------------
    trunk/matplotlib/examples/api/hinton_demo.py
    trunk/matplotlib/lib/mpl_toolkits/axisartist/angle_helper.py

Modified: trunk/matplotlib/examples/api/hinton_demo.py
===================================================================
--- trunk/matplotlib/examples/api/hinton_demo.py        2010-07-06 01:05:28 UTC 
(rev 8498)
+++ trunk/matplotlib/examples/api/hinton_demo.py        2010-07-06 01:24:58 UTC 
(rev 8499)
@@ -8,7 +8,7 @@
 
 def hinton(W, maxWeight=None, ax=None):
     """
-    Draws a Hinton diagram for visualizing a weight matrix. 
+    Draws a Hinton diagram for visualizing a weight matrix.
     """
     if not ax:
         fig = plt.figure()
@@ -23,13 +23,14 @@
     ax.yaxis.set_major_locator(NullLocator())
 
     for (x,y),w in np.ndenumerate(W):
-        color = 'white' if w > 0 else 'black'
+        if w > 0: color = 'white'
+        else:     color = 'black'
         size = np.sqrt(np.abs(w))
         rect = Rectangle([x - size / 2, y - size / 2], size, size,
             facecolor=color, edgecolor=color)
         ax.add_patch(rect)
     ax.autoscale_view()
-    
+
     # Reverse the yaxis limits
     ax.set_ylim(*ax.get_ylim()[::-1])
 

Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/angle_helper.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axisartist/angle_helper.py        
2010-07-06 01:05:28 UTC (rev 8498)
+++ trunk/matplotlib/lib/mpl_toolkits/axisartist/angle_helper.py        
2010-07-06 01:24:58 UTC (rev 8499)
@@ -179,7 +179,9 @@
     def __call__(self, direction, factor, values): # hour
         if len(values) == 0:
             return []
-        ss = [[-1, 1][v>0] for v in values]
+        #ss = [[-1, 1][v>0] for v in values]  #not py24 compliant
+        values = np.asarray(values)
+        ss = np.where(values>0, 1, -1)
         values = np.abs(values)/15.
 
         if factor == 1:
@@ -221,7 +223,9 @@
     def __call__(self, direction, factor, values):
         if len(values) == 0:
             return []
-        ss = [[-1, 1][v>0] for v in values]
+        #ss = [[-1, 1][v>0] for v in values] #not py24 compliant
+        values = np.asarray(values)
+        ss = np.where(values>0, 1, -1)
         values = np.abs(values)
         if factor == 1:
             return ["$%d^{\circ}$" % (s*int(v),) for (s, v) in zip(ss, values)]


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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to