On Thu, May 21, 2009 at 12:35 PM, Tony S Yu <ton...@mit.edu> wrote:
> I'm animating a Circle patch with a varying center and radius, and I noticed
> that changing the ``radius`` attribute has no effect on the patch.
> Currently, ``radius`` is only used to instantiate an Ellipse object, but
> updating radius has no effect (i.e. redrawing the patch doesn't use the new
> radius).
> I've included a patch to add this feature. Also included in the patch is a
> small fix to one of the UI examples (sorry for included a completely
> unrelated patch but the fix seemed to small for a separate email).
> BTW, I'm using a property idiom
> from: http://code.activestate.com/recipes/205183/. I thought that this
> approach was better than polluting the namespace with getters and setters,
> especially since this would differ from the way the Ellipse class uses
> ``width`` and ``height`` attributes.


Thanks Tony -- I committed this with a change.  The mpl getters and
setters, as well as the ACCEPTS line,  are used in the object
introspection and doc building, so the way to add a property like
radius is:


    def set_radius(self, radius):
        """
        Set the radius of the circle

        ACCEPTS: float
        """
        self.width = self.height = 2 * radius

    def get_radius(self):
        'return the radius of the circle'
        return self.width / 2.

    radius = property(get_radius, set_radius)

but as I look through patches, I notice there are a number of places
(eg RegularPolygon) where hidden methods w/o docstrings are used.  I
assume Michael wrote most of these in the transforms refactorring.
Was this a conscious decision to hide them from the doc proprty
introspection mechanism?

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to