SF.net SVN: matplotlib:[5786] trunk/matplotlib/lib/matplotlib

2008-07-18 Thread dmkaplan
Revision: 5786
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5786&view=rev
Author:   dmkaplan
Date: 2008-07-18 08:43:03 + (Fri, 18 Jul 2008)

Log Message:
---
Making a number of changes related to "blocking" stuff:

1) Adding to cbook.py a method is_sequence_of_strings that is then used in
   BlockingInput to test for a tuple-like sequence of event names

2) Modified the use of *fmt* in clabel so that it an also be a
   dictionary matching contour levels to arbitrary strings.

3) Removing the extraneous np.array or np.asarray commands in ContourLabeler
   as they were forcing linecontour to array, but linecontour should already
   be an array.

4) In blocking_input.py replacing all print commands with calls to 
   matplotlib.verbose.report

5) Removing extra cleanup call from BlockingInput as finally is always
   executed, regardless of exception status.

6) Removing what appears to be a "patch" command screwup - there were two
   versions of several of the Blocking* classes in blocking_input.py

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/blocking_input.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/lib/matplotlib/figure.py

Modified: trunk/matplotlib/lib/matplotlib/blocking_input.py
===
--- trunk/matplotlib/lib/matplotlib/blocking_input.py   2008-07-17 21:06:17 UTC 
(rev 5785)
+++ trunk/matplotlib/lib/matplotlib/blocking_input.py   2008-07-18 08:43:03 UTC 
(rev 5786)
@@ -19,7 +19,8 @@
 
 import time
 import numpy as np
-import matplotlib.path as path
+from matplotlib import path, verbose
+from cbook import is_sequence_of_strings
 
 class BlockingInput(object):
 """
@@ -28,7 +29,7 @@
 """
 def __init__(self, fig, eventslist=()):
 self.fig = fig
-assert isinstance(eventslist, tuple), "Requires a tuple of event name 
strings"
+assert is_sequence_of_strings(eventslist), "Requires a sequence of 
event name strings"
 self.eventslist = eventslist
 
 def on_event(self, event):
@@ -41,8 +42,7 @@
 # subclasses
 self.add_event(event)
 
-if self.verbose:
-print "Event %i" % len(self.events)
+verbose.report("Event %i" % len(self.events))
 
 # This will extract info from events
 self.post_event()
@@ -80,7 +80,7 @@
 self.pop_event(index)
 pop.__doc__=pop_event.__doc__
 
-def __call__(self, n=1, timeout=30, verbose=False ):
+def __call__(self, n=1, timeout=30 ):
 """
 Blocking call to retrieve n events
 """
@@ -90,7 +90,6 @@
 
 self.events = []
 self.done = False
-self.verbose = verbose
 self.callbacks = []
 
 # Ensure that the figure is shown
@@ -112,12 +111,10 @@
 if timeout > 0 and counter > timeout/0.01:
 print "Timeout reached";
 break;
-finally: # Activated on exception like ctrl-c
+finally: # Run even on exception like ctrl-c
+# Disconnect the callbacks
 self.cleanup()
 
-# Disconnect the callbacks
-self.cleanup()
-
 # Return the events in this case
 return self.events
 
@@ -196,10 +193,10 @@
 This add the coordinates of an event to the list of clicks
 """
 self.clicks.append((event.xdata,event.ydata))
-if self.verbose:
-print "input %i: %f,%f" % (len(self.clicks),
-   event.xdata, event.ydata)
 
+verbose.report("input %i: %f,%f" % 
+   (len(self.clicks),event.xdata, event.ydata))
+
 # If desired plot up click
 if self.show_clicks:
 self.marks.extend(
@@ -238,7 +235,7 @@
 # Call base class to remove callbacks
 BlockingInput.cleanup(self)
 
-def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
+def __call__(self, n=1, timeout=30, show_clicks=True):
 """
 Blocking call to retrieve n coordinate pairs through mouse
 clicks.
@@ -246,7 +243,7 @@
 self.show_clicks = show_clicks
 self.clicks  = []
 self.marks   = []
-BlockingInput.__call__(self,n=n,timeout=timeout,verbose=verbose)
+BlockingInput.__call__(self,n=n,timeout=timeout)
 
 return self.clicks
 
@@ -324,7 +321,7 @@
 
 def __call__(self,inline,n=-1,timeout=-1):
 self.inline=inline
-BlockingMouseInput.__call__(self,n=n,timeout=timeout,verbose=False,
+BlockingMouseInput.__call__(self,n=n,timeout=timeout,
 show_clicks=False)
 
 class BlockingKeyMouseInput(BlockingInput):
@@ -343,198 +340,13 @@
 
 self.keyormouse = self.events[-1].name == 'key_press_event'
 
-def __call__(self, timeout=30, verbose=False):
+def __call__(self, time

SF.net SVN: matplotlib:[5787] branches/v0_91_maint/lib/matplotlib/patches. py

2008-07-18 Thread jdh2358
Revision: 5787
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5787&view=rev
Author:   jdh2358
Date: 2008-07-18 14:46:32 + (Fri, 18 Jul 2008)

Log Message:
---
added Tuukka's YAArrow fix for horiz and vertical lines

Modified Paths:
--
branches/v0_91_maint/lib/matplotlib/patches.py

Modified: branches/v0_91_maint/lib/matplotlib/patches.py
===
--- branches/v0_91_maint/lib/matplotlib/patches.py  2008-07-18 08:43:03 UTC 
(rev 5786)
+++ branches/v0_91_maint/lib/matplotlib/patches.py  2008-07-18 14:46:32 UTC 
(rev 5787)
@@ -712,6 +712,12 @@
 and the distance from x2,y2 ot the returned points is k
 """
 x1,y1,x2,y2,k = map(float, (x1,y1,x2,y2,k))
+
+if y2-y1 == 0:
+return x2, y2+k, x2, y2-k
+elif x2-x1 == 0:
+return x2+k, y2, x2-k, y2
+
 m = (y2-y1)/(x2-x1)
 pm = -1./m
 a = 1


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[5788] trunk/matplotlib

2008-07-18 Thread jdh2358
Revision: 5788
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5788&view=rev
Author:   jdh2358
Date: 2008-07-18 14:49:09 + (Fri, 18 Jul 2008)

Log Message:
---
Merged revisions 5787 via svnmerge from 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint


  r5787 | jdh2358 | 2008-07-18 09:46:32 -0500 (Fri, 18 Jul 2008) | 1 line
  
  added Tuukka's YAArrow fix for horiz and vertical lines


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

Property Changed:

trunk/matplotlib/


Property changes on: trunk/matplotlib
___
Modified: svnmerge-integrated
   - /branches/v0_91_maint:1-5771
   + /branches/v0_91_maint:1-5787

Modified: trunk/matplotlib/lib/matplotlib/patches.py
===
--- trunk/matplotlib/lib/matplotlib/patches.py  2008-07-18 14:46:32 UTC (rev 
5787)
+++ trunk/matplotlib/lib/matplotlib/patches.py  2008-07-18 14:49:09 UTC (rev 
5788)
@@ -858,6 +858,12 @@
 *y2*) of the returned points is *k*.
 """
 x1,y1,x2,y2,k = map(float, (x1,y1,x2,y2,k))
+
+if y2-y1 == 0:
+return x2, y2+k, x2, y2-k
+elif x2-x1 == 0:
+return x2+k, y2, x2-k, y2
+
 m = (y2-y1)/(x2-x1)
 pm = -1./m
 a = 1


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[5789] trunk/matplotlib/lib/matplotlib/cbook.py

2008-07-18 Thread dmkaplan
Revision: 5789
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5789&view=rev
Author:   dmkaplan
Date: 2008-07-18 18:59:57 + (Fri, 18 Jul 2008)

Log Message:
---
Fixing bug in is_sequence_of_strings.

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

Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===
--- trunk/matplotlib/lib/matplotlib/cbook.py2008-07-18 14:49:09 UTC (rev 
5788)
+++ trunk/matplotlib/lib/matplotlib/cbook.py2008-07-18 18:59:57 UTC (rev 
5789)
@@ -275,6 +275,7 @@
 Returns true if *obj* is iterable and contains strings
 """
 if not iterable(obj): return False
+if is_string_like(obj): return False
 for o in obj:
 if not is_string_like(o): return False
 return True


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[5790] trunk/matplotlib/lib/matplotlib/backends/ backend_gtk.py

2008-07-18 Thread jdh2358
Revision: 5790
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5790&view=rev
Author:   jdh2358
Date: 2008-07-18 20:43:58 + (Fri, 18 Jul 2008)

Log Message:
---
restored gtk quit on window close

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-07-18 
18:59:57 UTC (rev 5789)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-07-18 
20:43:58 UTC (rev 5790)
@@ -459,9 +459,9 @@
 if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
gtk.main_level() >= 1:
-#gtk.main_quit()
-pass
+gtk.main_quit()
 
+
 def show(self):
 # show the figure window
 self.window.show()


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[5791] trunk/matplotlib

2008-07-18 Thread astraw
Revision: 5791
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5791&view=rev
Author:   astraw
Date: 2008-07-18 23:15:37 + (Fri, 18 Jul 2008)

Log Message:
---
Check for nan and inf in axes.delete_masked_points().

Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py

Added Paths:
---
trunk/matplotlib/unit/axes_unit.py

Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG  2008-07-18 20:43:58 UTC (rev 5790)
+++ trunk/matplotlib/CHANGELOG  2008-07-18 23:15:37 UTC (rev 5791)
@@ -1,3 +1,6 @@
+2008-07-18 Check for nan and inf in axes.delete_masked_points().
+  This should help hexbin and scatter deal with nans. - ADS
+
 2008-07-17 Added ability to manually select contour label locations.
   Also added a waitforbuttonpress function. - DMK
 

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-07-18 20:43:58 UTC (rev 
5790)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-07-18 23:15:37 UTC (rev 
5791)
@@ -1,5 +1,5 @@
 from __future__ import division, generators
-import math, sys, warnings, datetime, new
+import math, sys, warnings, datetime, new, types
 
 import numpy as np
 from numpy import ma
@@ -36,6 +36,8 @@
 Find all masked points in a set of arguments, and return
 the arguments with only the unmasked points remaining.
 
+This will also delete any points that are not finite (nan or inf).
+
 The overall mask is calculated from any masks that are present.
 If a mask is found, any argument that does not have the same
 dimensions is left unchanged; therefore the argument list may
@@ -49,9 +51,11 @@
 useful.
 """
 masks = [ma.getmaskarray(x) for x in args if hasattr(x, 'mask')]
+isfinite = [np.isfinite(x) for x in args]
+masks.extend( [~x for x in isfinite if not 
isinstance(x,types.NotImplementedType)] )
 if len(masks) == 0:
 return args
-mask = reduce(ma.mask_or, masks)
+mask = reduce(np.logical_or, masks)
 margs = []
 for x in args:
 if (not is_string_like(x)

Added: trunk/matplotlib/unit/axes_unit.py
===
--- trunk/matplotlib/unit/axes_unit.py  (rev 0)
+++ trunk/matplotlib/unit/axes_unit.py  2008-07-18 23:15:37 UTC (rev 5791)
@@ -0,0 +1,62 @@
+import unittest
+import numpy as np
+import matplotlib.axes as axes
+
+class TestAxes(unittest.TestCase):
+def test_delete_masked_points_arrays(self):
+input = (   [1,2,3,np.nan,5],
+np.array((1,2,3,4,5)),
+)
+expected = [np.array((1,2,3,5))]*2
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+input = (   np.ma.array( [1,2,3,4,5], 
mask=[False,False,False,True,False] ),
+np.array((1,2,3,4,5)),
+)
+expected = [np.array((1,2,3,5))]*2
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+input = (   [1,2,3,np.nan,5],
+np.ma.array( [1,2,3,4,5], 
mask=[False,False,False,True,False] ),
+np.array((1,2,3,4,5)),
+)
+expected = [np.array((1,2,3,5))]*3
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+input = ()
+expected = ()
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+
+input = (   [1,2,3,np.nan,5],
+)
+expected = [np.array((1,2,3,5))]*1
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+input = (   np.array((1,2,3,4,5)),
+)
+expected = [np.array((1,2,3,4,5))]*1
+actual = axes.delete_masked_points(*input)
+assert np.allclose(actual, expected)
+
+def test_delete_masked_points_strings(self):
+input = (   'hello',
+)
+expected = ('hello',)
+actual = axes.delete_masked_points(*input)
+assert actual == expected
+
+input = (   u'hello',
+)
+expected = (u'hello',)
+actual = axes.delete_masked_points(*input)
+assert actual == expected
+
+
+if __name__=='__main__':
+unittest.main()


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 t