SF.net SVN: matplotlib:[7767] trunk/matplotlib/lib/matplotlib/sphinxext/ plot_directive.py

2009-09-16 Thread mdboom
Revision: 7767
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7767&view=rev
Author:   mdboom
Date: 2009-09-16 14:12:27 + (Wed, 16 Sep 2009)

Log Message:
---
Minor fixes to plot_directive

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py

Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
===
--- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2009-09-15 
20:10:35 UTC (rev 7766)
+++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2009-09-16 
14:12:27 UTC (rev 7767)
@@ -153,7 +153,7 @@
 (os.path.exists(original) and
  os.stat(derived).st_mtime < os.stat(original).st_mtime))
 
-def import_file(plot_path, function_name):
+def run_code(plot_path, function_name, plot_code):
 """
 Import a Python module from a path, and run the function given by
 name, if function_name is not None.
@@ -161,29 +161,62 @@
 # Change the working directory to the directory of the example, so
 # it can get at its data files, if any.  Add its path to sys.path
 # so it can import any helper modules sitting beside it.
-pwd = os.getcwd()
-path, fname = os.path.split(plot_path)
-sys.path.insert(0, os.path.abspath(path))
-stdout = sys.stdout
-sys.stdout = cStringIO.StringIO()
-os.chdir(path)
-try:
-fd = open(fname)
-module = imp.load_module(
-"__main__", fd, fname, ('py', 'r', imp.PY_SOURCE))
-finally:
-del sys.path[0]
-os.chdir(pwd)
-sys.stdout = stdout
-fd.close()
+if plot_code is not None:
+exec(plot_code)
+else:
+pwd = os.getcwd()
+path, fname = os.path.split(plot_path)
+sys.path.insert(0, os.path.abspath(path))
+stdout = sys.stdout
+sys.stdout = cStringIO.StringIO()
+os.chdir(path)
+try:
+fd = open(fname)
+module = imp.load_module(
+"__plot__", fd, fname, ('py', 'r', imp.PY_SOURCE))
+finally:
+del sys.path[0]
+os.chdir(pwd)
+sys.stdout = stdout
+fd.close()
 
-if function_name is not None:
-print "function_name", function_name
-getattr(module, function_name)()
+if function_name is not None:
+getattr(module, function_name)()
 
-return module
+def run_savefig(plot_path, basename, tmpdir, destdir, formats):
+"""
+Once a plot script has been imported, this function runs savefig
+on all of the figures in all of the desired formats.
+"""
+fig_managers = _pylab_helpers.Gcf.get_all_fig_managers()
+for i, figman in enumerate(fig_managers):
+for j, (format, dpi) in enumerate(formats):
+if len(fig_managers) == 1:
+outname = basename
+else:
+outname = "%s_%02d" % (basename, i)
+outname = outname + "." + format
+outpath = os.path.join(tmpdir, outname)
+try:
+figman.canvas.figure.savefig(outpath, dpi=dpi)
+except:
+s = cbook.exception_to_str("Exception saving plot %s" % 
plot_path)
+warnings.warn(s)
+return 0
+if j > 0:
+shutil.copyfile(outpath, os.path.join(destdir, outname))
 
-def render_figures(plot_path, function_name, plot_code, outdir, formats):
+return len(fig_managers)
+
+def clear_state():
+plt.close('all')
+matplotlib.rcdefaults()
+# Set a default figure size that doesn't overflow typical browser
+# windows.  The script is free to override it if necessary.
+matplotlib.rcParams['figure.figsize'] = (5.5, 4.5)
+
+def render_figures(plot_path, function_name, plot_code, tmpdir, destdir,
+   formats):
 """
 Run a pyplot script and save the low and high res PNGs and a PDF
 in outdir.
@@ -196,7 +229,7 @@
 
 # Look for single-figure output files first
 for format, dpi in formats:
-outname = os.path.join(outdir, '%s.%s' % (basename, format))
+outname = os.path.join(tmpdir, '%s.%s' % (basename, format))
 if out_of_date(plot_path, outname):
 all_exists = False
 break
@@ -211,7 +244,7 @@
 all_exists = True
 for format, dpi in formats:
 outname = os.path.join(
-outdir, '%s_%02d.%s' % (basename, i, format))
+tmpdir, '%s_%02d.%s' % (basename, i, format))
 if out_of_date(plot_path, outname):
 all_exists = False
 break
@@ -225,39 +258,20 @@
 
 # We didn't find the files, so build them
 
-# Clear any existing figures
-plt.close('all')
-matplotlib.rcdefaults()
-# Set a default figure size that doesn't overflow typical browser
-# windows.  The script is free to override it if n

SF.net SVN: matplotlib:[7768] trunk/matplotlib/doc/sphinxext/gen_gallery.py

2009-09-16 Thread mdboom
Revision: 7768
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7768&view=rev
Author:   mdboom
Date: 2009-09-16 14:12:49 + (Wed, 16 Sep 2009)

Log Message:
---
Minor fix to gen_gallery to ensure multiprocessing code path works

Modified Paths:
--
trunk/matplotlib/doc/sphinxext/gen_gallery.py

Modified: trunk/matplotlib/doc/sphinxext/gen_gallery.py
===
--- trunk/matplotlib/doc/sphinxext/gen_gallery.py   2009-09-16 14:12:27 UTC 
(rev 7767)
+++ trunk/matplotlib/doc/sphinxext/gen_gallery.py   2009-09-16 14:12:49 UTC 
(rev 7768)
@@ -110,6 +110,8 @@
 app.builder.info("generating thumbnails... ", nonl=True)
 pool = multiprocessing.Pool()
 pool.map(make_thumbnail, thumbnails.iteritems())
+pool.close()
+pool.join()
 app.builder.info("done")
 
 except ImportError:


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:[7769] trunk/matplotlib/examples/pylab_examples/ to_numeric.py

2009-09-16 Thread mdboom
Revision: 7769
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7769&view=rev
Author:   mdboom
Date: 2009-09-16 14:13:26 + (Wed, 16 Sep 2009)

Log Message:
---
Comment out image display so that documentation generation doesn't block.

Modified Paths:
--
trunk/matplotlib/examples/pylab_examples/to_numeric.py

Modified: trunk/matplotlib/examples/pylab_examples/to_numeric.py
===
--- trunk/matplotlib/examples/pylab_examples/to_numeric.py  2009-09-16 
14:12:49 UTC (rev 7768)
+++ trunk/matplotlib/examples/pylab_examples/to_numeric.py  2009-09-16 
14:13:26 UTC (rev 7769)
@@ -29,5 +29,5 @@
 X.shape = h, w, 3
 
 im = Image.fromstring( "RGB", (w,h), s)
-im.show()
+# im.show()
 


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:[7770] branches/v0_99_maint/lib/matplotlib/backends/ backend_wx.py

2009-09-16 Thread efiring
Revision: 7770
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7770&view=rev
Author:   efiring
Date: 2009-09-16 23:38:54 + (Wed, 16 Sep 2009)

Log Message:
---
Don't use wxversion with py2exe; fix by Werner Bruhin

Modified Paths:
--
branches/v0_99_maint/lib/matplotlib/backends/backend_wx.py

Modified: branches/v0_99_maint/lib/matplotlib/backends/backend_wx.py
===
--- branches/v0_99_maint/lib/matplotlib/backends/backend_wx.py  2009-09-16 
14:13:26 UTC (rev 7769)
+++ branches/v0_99_maint/lib/matplotlib/backends/backend_wx.py  2009-09-16 
23:38:54 UTC (rev 7770)
@@ -110,24 +110,25 @@
 
 missingwx = "Matplotlib backend_wx and backend_wxagg require wxPython >=2.8"
 
-try:
-import wxversion
-except ImportError:
-raise ImportError(missingwx)
+if not hasattr(sys, 'frozen'): # i.e., not py2exe
+try:
+import wxversion
+except ImportError:
+raise ImportError(missingwx)
 
-# Some early versions of wxversion lack AlreadyImportedError.
-# It was added around 2.8.4?
-try:
-_wx_ensure_failed = wxversion.AlreadyImportedError
-except AttributeError:
-_wx_ensure_failed = wxversion.VersionError
+# Some early versions of wxversion lack AlreadyImportedError.
+# It was added around 2.8.4?
+try:
+_wx_ensure_failed = wxversion.AlreadyImportedError
+except AttributeError:
+_wx_ensure_failed = wxversion.VersionError
 
-try:
-wxversion.ensureMinimal('2.8')
-except _wx_ensure_failed:
-pass
-# We don't really want to pass in case of VersionError, but when
-# AlreadyImportedError is not available, we have to.
+try:
+wxversion.ensureMinimal('2.8')
+except _wx_ensure_failed:
+pass
+# We don't really want to pass in case of VersionError, but when
+# AlreadyImportedError is not available, we have to.
 
 try:
 import wx
@@ -776,7 +777,7 @@
 bind(self, wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown)
 bind(self, wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDown)
 bind(self, wx.EVT_MIDDLE_UP, self._onMiddleButtonUp)
-   
+
 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
 
 self.macros = {} # dict from wx id to seq of macros
@@ -1257,7 +1258,7 @@
 if self.HasCapture(): self.ReleaseMouse()
 FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
 
-#Add middle button events  
+#Add middle button events
 def _onMiddleButtonDown(self, evt):
 """Start measuring on an axis."""
 x = evt.GetX()


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:[7771] trunk/matplotlib

2009-09-16 Thread efiring
Revision: 7771
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7771&view=rev
Author:   efiring
Date: 2009-09-16 23:42:07 + (Wed, 16 Sep 2009)

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


  r7770 | efiring | 2009-09-16 13:38:54 -1000 (Wed, 16 Sep 2009) | 2 lines
  
  Don't use wxversion with py2exe; fix by Werner Bruhin


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

Property Changed:

trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
trunk/matplotlib/examples/misc/multiprocess.py
trunk/matplotlib/examples/mplot3d/contour3d_demo.py
trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
trunk/matplotlib/examples/mplot3d/polys3d_demo.py
trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo.py
trunk/matplotlib/examples/mplot3d/wire3d_demo.py
trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py

trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_spines/spines_axes_positions.png


Property changes on: trunk/matplotlib
___
Modified: svnmerge-integrated
   - /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 
/branches/v0_99_maint:1-7757,7762
   + /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 
/branches/v0_99_maint:1-7770
Modified: svn:mergeinfo
   - /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638,7703,7727-7734,7740-7741,7745,7751,7756,7762
   + /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638,7703,7727-7734,7740-7741,7745,7751,7756,7762,7770


Property changes on: trunk/matplotlib/doc/pyplots/README
___
Modified: svn:mergeinfo
   - 
/branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638,7703,7727-7734,7740-7741,7745,7751,7756,7762
   + 
/branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638,7703,7727-7734,7740-7741,7745,7751,7756,7762,7770


Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___
Modified: svn:mergeinfo
   - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6