[SciPy-user] Polynomial interpolation

Robert Kern robert.kern at gmail.com
Wed Apr 30 04:40:38 EDT 2008


On Wed, Apr 30, 2008 at 3:03 AM, Anne Archibald
<peridot.faceted at gmail.com> wrote:
> 2008/4/30 Robert Kern <robert.kern at gmail.com>:
>
> > On Wed, Apr 30, 2008 at 2:03 AM, Anne Archibald
>  >
>  > <peridot.faceted at gmail.com> wrote:
>  >
>  >  >  I can clean those up. But I'm not sure how to set things up as
>  >  >  "properties" so that the right things happen when users try to
>  >  >  manipulate the attributes.
>  >
>  >  If it doesn't feel right to you, don't do it. Your point about
>  >  properies giving a false sense of safety in this case is quite valid.
>  >  If it's not obvious how to apply properties nicely here, that might be
>  >  a good sign that properties aren't appropriate.
>
>  Well, actually what I meant was I've never used properties at all and
>  didn't find any useful documentation. I had in mind a fairly draconian
>  configuration that made nearly everything readonly, though I suppose
>  that would become cumbersome within my own methods.

Properties Lesson #1: Don't do that.  :-)

Properties are useful to add functionality, or to expose functionality
with attribute syntax, which may be appropriate. *Removing*
functionality is not a good use of properties.

But anyways, the general solution for the internal cumbersomeness is
to not use the properties internally. Instead, the property should map
to a _private attribute, and internally, you just manipulate those.

>  And anyway it
>  doesn't really work for numpy arrays, since someone can always do b =
>  A.unwritable_array; b[i,j]=3. But set_yi is a bit ugly.

All things considered, it's fine. Call it update_yi() if you feel it's
more appropriate.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the SciPy-User mailing list