SF.net SVN: matplotlib:[7831] trunk/matplotlib/lib/matplotlib/testing

2009-09-28 Thread jouni
Revision: 7831
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7831&view=rev
Author:   jouni
Date: 2009-09-28 17:40:49 + (Mon, 28 Sep 2009)

Log Message:
---
Make it not an error if the system does not have gs

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/testing/compare.py
trunk/matplotlib/lib/matplotlib/testing/decorators.py

Modified: trunk/matplotlib/lib/matplotlib/testing/compare.py
===
--- trunk/matplotlib/lib/matplotlib/testing/compare.py  2009-09-27 19:06:37 UTC 
(rev 7830)
+++ trunk/matplotlib/lib/matplotlib/testing/compare.py  2009-09-28 17:40:49 UTC 
(rev 7831)
@@ -3,18 +3,21 @@
 """
 #===
 
+import matplotlib
 import math
 import operator
 import os
 import numpy as np
 import shutil
 import subprocess
+import sys
 
 #===
 
 __all__ = [
 'compare_float',
 'compare_images',
+'comparable_formats',
   ]
 
 #---
@@ -77,17 +80,32 @@
 # A dictionary that maps filename extensions to functions that map
 # parameters old and new to a list that can be passed to Popen to
 # convert files with that extension to png format.
-converter = { 'pdf': lambda old, new: \
- ['gs', '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
-  '-sOutputFile=' + new, old],
-  }
+converter = { }
+
+if matplotlib.checkdep_ghostscript() is not None:
+   # FIXME: make checkdep_ghostscript return the command
+   if sys.platform == 'win32':
+  gs = 'gswin32c'
+   else:
+  gs = 'gs'
+   cmd = lambda old, new: \
+   [gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
+'-sOutputFile=' + new, old]
+   converter['pdf'] = cmd
+   converter['eps'] = cmd
+
+def comparable_formats():
+   '''Returns the list of file formats that compare_images can compare
+   on this system.'''
+   return ['png'] + converter.keys()
+
 def convert(filename):
'''Convert the named file into a png file.
Returns the name of the created file.
'''
base, extension = filename.rsplit('.', 1)
if extension not in converter:
-  raise KeyError, "Don't know how to convert %s files to png" % extension
+  raise NotImplementedError, "Don't know how to convert %s files to png" % 
extension
newname = base + '_' + extension + '.png'
cmd = converter[extension](filename, newname)
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py   2009-09-27 
19:06:37 UTC (rev 7830)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py   2009-09-28 
17:40:49 UTC (rev 7831)
@@ -4,7 +4,7 @@
 import nose
 import matplotlib
 import matplotlib.tests
-from matplotlib.testing.compare import compare_images
+from matplotlib.testing.compare import comparable_formats, compare_images
 
 def knownfailureif(fail_condition, msg=None):
 """
@@ -88,6 +88,11 @@
 for fname in baseline_images:
 actual = os.path.join(result_dir, fname) + '.' + extension
 expected = os.path.join(baseline_dir,fname) + '.' + 
extension
+if (extension not in comparable_formats()
+or not os.path.exists(expected)):
+# FIXME: Should it be a known fail if this format
+# cannot be compared in this environment?
+continue
 
 # compare the images
 tol=1e-3 # default tolerance


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

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7832] trunk/matplotlib/lib/matplotlib/pyplot.py

2009-09-28 Thread ryanmay
Revision: 7832
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7832&view=rev
Author:   ryanmay
Date: 2009-09-28 21:58:10 + (Mon, 28 Sep 2009)

Log Message:
---
Update a couple of remaining uses of gci._current to sci().

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

Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===
--- trunk/matplotlib/lib/matplotlib/pyplot.py   2009-09-28 17:40:49 UTC (rev 
7831)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py   2009-09-28 21:58:10 UTC (rev 
7832)
@@ -401,7 +401,7 @@
 # allow callers to override the hold state by passing hold=True|False
 ret =  gcf().figimage(*args, **kwargs)
 draw_if_interactive()
-gci._current = ret
+sci(ret)
 return ret
 
 def figlegend(handles, labels, loc, **kwargs):
@@ -1444,7 +1444,7 @@
 ax  = fig.add_axes([0.15, 0.09, 0.775, 0.775])
 
 im = ax.matshow(A, **kw)
-gci._current = im
+sci(im)
 
 draw_if_interactive()
 return im
@@ -2629,7 +2629,3 @@
 if im is not None:
 im.set_cmap(cm.spectral)
 draw_if_interactive()
-
-
-
-


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

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7833] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/__init__.py

2009-09-28 Thread ryanmay
Revision: 7833
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7833&view=rev
Author:   ryanmay
Date: 2009-09-28 22:12:38 + (Mon, 28 Sep 2009)

Log Message:
---
Update to be compatible with matplotlib trunk's new method of tracking the 
current image.

Modified Paths:
--
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py

Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-09-28 
21:58:10 UTC (rev 7832)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-09-28 
22:12:38 UTC (rev 7833)
@@ -2567,7 +2567,10 @@
 ax.hold(b)
 # reset current active image (only if pyplot is imported).
 try:
-plt.gci._current = ret
+try:
+plt.sci(ret)
+except AttributeError:
+plt.gci._current = ret
 except:
 pass
 # set axes limits to fit map region.
@@ -2642,7 +2645,10 @@
 ax.hold(b)
 # reset current active image (only if pyplot is imported).
 try:
-plt.gci._current = ret
+try:
+plt.sci(ret)
+except AttributeError:
+plt.gci._current = ret
 except:
 pass
 # set axes limits to fit map region.
@@ -2687,7 +2693,10 @@
 ax.hold(b)
 # reset current active image (only if pyplot is imported).
 try:
-plt.gci._current = ret
+try:
+plt.sci(ret)
+except AttributeError:
+plt.gci._current = ret
 except:
 pass
 # set axes limits to fit map region.
@@ -2724,7 +2733,10 @@
 ax.hold(b)
 # reset current active image (only if pyplot is imported).
 try:
-plt.gci._current = ret
+try:
+plt.sci(ret)
+except AttributeError:
+plt.gci._current = ret
 except:
 pass
 # set axes limits to fit map region.
@@ -2788,9 +2800,17 @@
 # reset current active image (only if pyplot is imported).
 try:
 try: # new contour.
-if CS._A is not None: plt.gci._current = CS
+if CS._A is not None:
+try:
+plt.sci(CS)
+except AttributeError:
+plt.gci._current = CS
 except: # old contour.
-if CS[1].mappable is not None: plt.gci._current = 
CS[1].mappable
+if CS[1].mappable is not None:
+try:
+plt.sci(CS[1].mappable)
+except AttributeError:
+plt.gci._current = CS[1].mappable
 except:
 pass
 return CS
@@ -2863,9 +2883,17 @@
 # reset current active image (only if pyplot is imported).
 try:
 try: # new contour.
-if CS._A is not None: plt.gci._current = CS
+if CS._A is not None:
+try:
+plt.sci(CS)
+except AttributeError:
+plt.gci._current = CS
 except: # old contour.
-if CS[1].mappable is not None: plt.gci._current = 
CS[1].mappable
+if CS[1].mappable is not None:
+try:
+plt.sci(CS[1].mappable)
+except AttributeError:
+plt.gci._current = CS[1].mappable
 except:
 pass
 return CS


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

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins