Sage patches to matplotlib

Here are a few patches that we in Sage have been applying to our version of matplotlib. I'm wondering if some or all of these might be incorporated into matplotlib, or if not, if you could comment on these patches. I've updated the following diffs to be against 0.99.0. I've separated the patches with a bunch of dashes.

lib/matplotlib/cbook.py: The background information for this patch is found at http://trac.sagemath.org/sage_trac/ticket/1967 and http://groups.google.com/group/sage-support/browse_thread/thread/edcf2740f7276e6a?hl=en#78ee7d78a0a99f12

--- src/lib/matplotlib/cbook.py 2009-08-01 12:15:07.000000000 -0700
+++ patches/cbook.py 2009-08-08 23:15:21.000000000 -0700
@@ -14,7 +14,10 @@

-preferredencoding = locale.getpreferredencoding()
+try:
+ preferredencoding = locale.getpreferredencoding()
+except:
+ preferredencoding = None
  def unicode_safe(s):
     if preferredencoding is None: return unicode(s)

···

-----------------------------------------------------------------------------------------------------------------------------------------------

lib/matplotlib/patches.py: The comment attached to this patch was '* Add a patch for patches.py, which ignores the errors generated when trying to draw arrows that are "too short".' I actually made this patch, so if it isn't obvious what the patch is doing and why it was causing an error before, I can try to remember and construct an example.

--- src/lib/matplotlib/patches.py 2009-08-01 12:15:07.000000000 -0700
+++ patches/patches.py 2009-08-08 23:25:09.000000000 -0700
@@ -2326,15 +2326,21 @@
                 x, y = path.vertices[0]
                 insideA = inside_circle(x, y, shrinkA)
- left, right = split_path_inout(path, insideA)
- path = right
+ try:
+ left, right = split_path_inout(path, insideA)
+ path = right
+ except ValueError:
+ pass
              if shrinkB:
                 x, y = path.vertices[-1]
                 insideB = inside_circle(x, y, shrinkB)
- left, right = split_path_inout(path, insideB)
- path = left
+ try:
+ left, right = split_path_inout(path, insideB)
+ path = left
+ except ValueError:
+ pass
              return path

---------------------------------------------------------------------------------------------------------------------------------------
ttconv/pprdrv_tt2.cpp: This patch is *only* applied when `uname` = "SunOS". The comment is: Copy patched version of pprdrv_tt2.cpp for Solaris 10 that builds with gcc 4.3.2.

--- src/ttconv/pprdrv_tt2.cpp 2009-08-01 12:15:15.000000000 -0700
+++ patches/pprdrv_tt2.cpp 2009-08-08 23:33:24.000000000 -0700
@@ -104,7 +104,8 @@
     { /* have a log of points. */
     if(stack_depth == 0)
         {
- stream.put_char('{');
+ // Note the below is a hack to make it compile on Solaris 10 with gcc 4.3.2
+ stream.puts("{");
             stack_depth=1;
             }

--------------------------------------------------------------------------------------------------------------------------------------------

setupext.py: The background for this patch is here: http://trac.sagemath.org/sage_trac/ticket/4176

--- src/setupext.py 2009-08-01 12:15:24.000000000 -0700
+++ patches/setupext.py 2009-08-08 23:43:29.000000000 -0700
@@ -1034,6 +1038,7 @@
         # of distros.
          # Query Tcl/Tk system for library paths and version string
+ tk_ver = ''
         try:
             tcl_lib_dir, tk_lib_dir, tk_ver = query_tcltk()
         except:

Thanks!

Jason

Here are a few patches that we in Sage have been applying to our version of matplotlib. I'm wondering if some or all of these might be incorporated into matplotlib, or if not, if you could comment on these patches. I've updated the following diffs to be against 0.99.0. I've separated the patches with a bunch of dashes.

Jason,

I have committed versions of all but the third to the v0.99 branch. Please check svn r7442-7444. I also propagated them to the trunk. If you have any questions or reservations about the modifications I made, please raise them! (The modification to #1 is because blanket "except:" is highly discouraged in mpl, and seemed unnecessary here. The modification to #4 is for code clarity, to make it even more obvious that the empty string is used as the version only in case of an exception.)

I did not commit #3. Apart from my lack of c++ expertise, I don't know how to implement it so that it takes effect only in the Solaris case. Therefore I am leaving this for John; or maybe he will pass it to Mike when he comes back from vacation. Below, I am deleting all but #3, to make it easier for John to see what we are talking about.

Eric

···

jason-sage@...691... wrote:

---------------------------------------------------------------------------------------------------------------------------------------
ttconv/pprdrv_tt2.cpp: This patch is *only* applied when `uname` = "SunOS". The comment is: Copy patched version of pprdrv_tt2.cpp for Solaris 10 that builds with gcc 4.3.2.

--- src/ttconv/pprdrv_tt2.cpp 2009-08-01 12:15:15.000000000 -0700
+++ patches/pprdrv_tt2.cpp 2009-08-08 23:33:24.000000000 -0700
@@ -104,7 +104,8 @@
     { /* have a log of points. */
     if(stack_depth == 0)
         {
- stream.put_char('{');
+ // Note the below is a hack to make it compile on Solaris 10 with gcc 4.3.2
+ stream.puts("{");
             stack_depth=1;
             }

--------------------------------------------------------------------------------------------------------------------------------------------

I can try and take a look at this tomorrow. I do have a solaris box
at work to test on, but we are on an older version of gcc. Ideally,
we could find a c preprocessor macro to indicate the platform rather
than do an uname conditioned patch. If anyone knows of a platform
macro for solaris to check for, let me know.

JDH

···

On Sun, Aug 9, 2009 at 7:48 PM, Eric Firing<efiring@...229...> wrote:

I did not commit #3. Apart from my lack of c++ expertise, I don't know how
to implement it so that it takes effect only in the Solaris case. Therefore
I am leaving this for John; or maybe he will pass it to Mike when he comes
back from vacation. Below, I am deleting all but #3, to make it easier for
John to see what we are talking about.

John Hunter wrote:

I did not commit #3. Apart from my lack of c++ expertise, I don't know how
to implement it so that it takes effect only in the Solaris case. Therefore
I am leaving this for John; or maybe he will pass it to Mike when he comes
back from vacation. Below, I am deleting all but #3, to make it easier for
John to see what we are talking about.
    
I can try and take a look at this tomorrow. I do have a solaris box
at work to test on, but we are on an older version of gcc. Ideally,
we could find a c preprocessor macro to indicate the platform rather
than do an uname conditioned patch. If anyone knows of a platform
macro for solaris to check for, let me know.

We have some people in the Sage project who know Solaris very well and
are actively porting Sage and the projects Sage contains to Solaris. I
have therefore posted your message to the sage-devel list, and can
forward replies from there to here.

See
http://groups.google.com/group/sage-devel/browse_thread/thread/ae13e25616779f64

Thanks,

Jason

···

On Sun, Aug 9, 2009 at 7:48 PM, Eric Firing<efiring@...229...> wrote: