2010/9/13 Benjamin Root <ben.r...@ou.edu>:
> On Tue, Aug 31, 2010 at 9:08 PM, Benjamin Root <ben.r...@ou.edu> wrote:
>> I have been working on a couple of interesting concoctions for
>> matplotlib.  The first is a wrapper class called "ThinWrap" that,
>> essentially, provides a way to create objects that are linked to a given
>> object.  These objects can then be subclassed for some very interesting
>> behaviors.  Which leads me to my ReMap class.
>>
>> The ReMap class is designed to be a wrapper around a Colormap object, and
>> the __call__ function is overloaded so that some other defined function can
>> modify the rgba values that comes from a call to the original colormap
>> object.  All of this is done without modifying the original colormap.  In
>> addition, a ReMap object can wrap another ReMap object, allowing for
>> stacking.  As an example, I have created a ToGrayscale() ReMap class.

I must admit that I have serious trouble accepting the need for this
idea.  To me, it seems like a not very elegant exploitation of Python
features in a way they aren't intended to be used.

Generally, I think, implementations shouldn't rely on the internals of
the implementation of object orientation, in a case like this, when
they try to expand the features of the object orientation the language
supplies.

I think you cannot speak of "subclassing" when creating a ThinWrap
object around another object?  (From your patch, it looks to me like
this.)

Furthermore, I'd say, this ThinWrap feature is neither specially
needed for matplotlib's usecase, nor is it widely accepted.  It is
like an independent package incorporated into matplotlib the hard way.
 I think this isn't the way is should be.  In that case, it may be a
dependency, which should be handled by easy_install or the user.

Benjamin, I believe this code is neat in idea, but not suited well for
Python.  I would refrain from checking it in.

Friedrich


P.S.: It seems to me like a forced generalisation of your original
idea of a wrap around the Colormap object.  If I would be you, I'd
restrict the usecase to Colormap, and implement a real class, which is
just a WrappedColormap, derived from Colormap, which can do the job by
overloading.

Right from the need that you have to circumvent normal isinstance()
checks, which shouldn't be an issue in a clear oo implementation of
your functionality, you can see that your approach is not well suited
in my opinion.

Don't be offended, I have to add.

I think you run into serious problems when trying to find a place for
the class of ThinWrap in the oo model.


Can you ask the authors of the pro posts to re-post their posts on the
list?  I'd be interested.

>> cm.py: get_cmap() could finish the function without returning anything.  I
>> modified it to remove the "isinstance" check that would cause
>> non-Colormap/non-string objects to  fall into a black hole.  We are gonna
>> have to follow duck-typing here...
>> colors.py: The Colormap class needs to be a new-style class for ReMap to
>> work properly
>> contour.py: Commented out code that did a isinstance() check on the cmap
>> that would cause ReMaps on contours to fail.
>>
>> I have also included an example script to demonstrate how this wrapper
>> class works and the ToGrayscale() class works.
>>
>> Let me know what you think!
>> Ben Root
>
> Just reping-ing this.  I haven't heard anything negative and got a few
> positive comments off-list.  I haven't committed this yet because I am
> concerned about the implications of my changes to cm.py, colors.py and
> contour.py.  However, if I don't hear any concerns over the next couple of
> days, shall I assume that it is ok to go ahead and commit?
>
> Ben Root

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to