A small fix for backend specification...

Hi folks,

I'd like to know if the fix below looks reasonable to you, this is a
diff against current svn trunk:

dreamweaver[matplotlib]> svn diff
Index: __init__.py

···

===================================================================
--- __init__.py (revision 8656)
+++ __init__.py (working copy)
@@ -880,10 +880,14 @@
     if 'matplotlib.backends' in sys.modules:
         if warn: warnings.warn(_use_error_msg)
         return
- arg = arg.lower()
     if arg.startswith('module://'):
         name = arg
     else:
+ # For non-module backends, normalize name to lowercase. Note that this
+ # must NOT be done to module backends, because those need to be valid
+ # Python module specifications that can be imported, and Python module
+ # names *are* case sensitive.
+ arg = arg.lower()
         be_parts = arg.split('.')
         name = validate_backend(be_parts[0])
         if len(be_parts) > 1:

##### END PATCH

I hope the comments explain clearly enough the problem. For a bit of
context, this is biting us in ipython where we're building a custom
backend for Qt terminals that inline mpl figures (very neat [1]), but
our backend's name is module://IPython.zmq.pylab.backend_payload_svg.
If you lowercase that, it won't import later. I know we shouldn't
have called IPython's module with that funny capitalization, but it's
a bit late to change now, I'm afraid.

Do you foresee any problems with the above change?

If everyone OK's it, I'm happy to commit it, but I won't do anything
until others better informed than I reply.

Regards,

f

[1] teaser for the curious:
http://fperez.org/tmp/ipython_qt_pylab.png. All code is in the
'newkernel' github branch. Special credits to Evan Patterson from
Enthought, the Qt brains behind the magic.

Freeking awesome!

Go go team!

Gaël

···

On Wed, Aug 25, 2010 at 02:57:50PM -0700, Fernando Perez wrote:

[1] teaser for the curious:
http://fperez.org/tmp/ipython_qt_pylab.png. All code is in the
'newkernel' github branch. Special credits to Evan Patterson from
Enthought, the Qt brains behind the magic.

Hi folks,

I'd like to know if the fix below looks reasonable to you, this is a
diff against current svn trunk:

dreamweaver[matplotlib]> svn diff
Index: __init__.py

--- __init__.py (revision 8656)
+++ __init__.py (working copy)
@@ -880,10 +880,14 @@
      if 'matplotlib.backends' in sys.modules:
          if warn: warnings.warn(_use_error_msg)
          return
- arg = arg.lower()
      if arg.startswith('module://'):
          name = arg
      else:
+ # For non-module backends, normalize name to lowercase. Note that this
+ # must NOT be done to module backends, because those need to be valid
+ # Python module specifications that can be imported, and Python module
+ # names *are* case sensitive.
+ arg = arg.lower()
          be_parts = arg.split('.')
          name = validate_backend(be_parts[0])
          if len(be_parts)> 1:

##### END PATCH

I hope the comments explain clearly enough the problem. For a bit of
context, this is biting us in ipython where we're building a custom
backend for Qt terminals that inline mpl figures (very neat [1]), but
our backend's name is module://IPython.zmq.pylab.backend_payload_svg.
If you lowercase that, it won't import later. I know we shouldn't
have called IPython's module with that funny capitalization, but it's
a bit late to change now, I'm afraid.

Do you foresee any problems with the above change?

If everyone OK's it, I'm happy to commit it, but I won't do anything
until others better informed than I reply.

Looks fine to me. It's fixing a bug. I don't think the comment is even necessary--the rationale looks pretty obvious, and the code is clear.

Eric

···

On 08/25/2010 11:57 AM, Fernando Perez wrote:

Regards,

f

[1] teaser for the curious:
http://fperez.org/tmp/ipython_qt_pylab.png. All code is in the
'newkernel' github branch. Special credits to Evan Patterson from
Enthought, the Qt brains behind the magic.

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

Thanks :slight_smile: We're pretty happy, we'll post more in a few weeks when
there's something more solid to show.

Take care,

f

···

On Wed, Aug 25, 2010 at 2:59 PM, Gael Varoquaux <gael.varoquaux@...427...> wrote:

Freeking awesome!

Go go team!

Great, thanks. I'll shorten the comment to just one line then:
+ # Lowercase only non-module backend names (modules are case-sensitive)

so that it serves as a little safety for the bug not to return, but is
less verbose than before.

Committed as revision 8657.

Thanks!

f

···

On Wed, Aug 25, 2010 at 3:06 PM, Eric Firing <efiring@...229...> wrote:

Looks fine to me. It's fixing a bug. I don't think the comment is even
necessary--the rationale looks pretty obvious, and the code is clear.