A small patch

Hi all,

here's a small patch for two little things I saw today:

1. The new mathtext has some unicode in it and on my system, python2.5
was throwing a syntax error due to the lack of an encoding
declaration. I just stuck utf-8 though I don't know if that's really
corrrect. Since the complaint was about characters in a comment it
doesn't matter too much, but it still might be a good idea to do the
right thing, so someone who actually knows should check what the right
value is.

2. Move a simple version check from runtime to class declaration time
in the cairo backend. While this causes a repeated line, the code is
small enough that it seems cleaner not to pay the version check on
every method call.

Cheers,

f

mpl_encod_cairo.diff (1.26 KB)

Fernando Perez wrote:

Hi all,

here's a small patch for two little things I saw today:

1. The new mathtext has some unicode in it and on my system, python2.5
was throwing a syntax error due to the lack of an encoding
declaration. I just stuck utf-8 though I don't know if that's really
corrrect. Since the complaint was about characters in a comment it
doesn't matter too much, but it still might be a good idea to do the
right thing, so someone who actually knows should check what the right
value is.

UTF-8 is my default system encoding, so I didn't catch this. I just fixed the comment (the unicode character is unnecessary to get the point across and wasonly in there due to a cut-and-paste accident anyway).

2. Move a simple version check from runtime to class declaration time
in the cairo backend. While this causes a repeated line, the code is
small enough that it seems cleaner not to pay the version check on
every method call.

I have committed this patch to SVN.

Cheers,
Mike

···

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

Index: lib/matplotlib/mathtext.py

--- lib/matplotlib/mathtext.py (revision 3715)
+++ lib/matplotlib/mathtext.py (working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
r"""
  OVERVIEW
Index: lib/matplotlib/backends/backend_gtkcairo.py

--- lib/matplotlib/backends/backend_gtkcairo.py (revision 3715)
+++ lib/matplotlib/backends/backend_gtkcairo.py (working copy)
@@ -29,12 +29,16 @@

- def set_pixmap (self, pixmap):
- if gtk.pygtk_version >= (2,7,0):
+ # Do the version check at class declaration time, so we don't pay for it on
+ # every invocation of the set_pixmap method.
+ if gtk.pygtk_version >= (2,7,0):
+ def set_pixmap (self, pixmap):
             self.ctx = pixmap.cairo_create()
- else:
+ self.ctx.save() # restore, save - when call new_gc()
+ else:
+ def set_pixmap (self, pixmap):
             self.ctx = cairo.gtk.gdk_cairo_create (pixmap)
- self.ctx.save() # restore, save - when call new_gc()
+ self.ctx.save() # restore, save - when call new_gc()

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

I thought last time this came up we agreed not to use unicode in the
src files. Is it possible to remove the unicode entirely?

JDH

···

On 8/20/07, Michael Droettboom <mdroe@...31...> wrote:

UTF-8 is my default system encoding, so I didn't catch this. I just
fixed the comment (the unicode character is unnecessary to get the point
across and wasonly in there due to a cut-and-paste accident anyway).

I have committed this patch to SVN.

John Hunter wrote:

···

On 8/20/07, Michael Droettboom <mdroe@...31...> wrote:

UTF-8 is my default system encoding, so I didn't catch this. I just
fixed the comment (the unicode character is unnecessary to get the point
across and wasonly in there due to a cut-and-paste accident anyway).

I have committed this patch to SVN.

I thought last time this came up we agreed not to use unicode in the
src files. Is it possible to remove the unicode entirely?

That's exactly what I did. Sorry I wasn't clear -- I only committed the second and unrelated patch to SVN (which eliminates a Gtk version check within a method call).

Cheers,
Mike