Re: [Numpy-discussion] Deprecate poly1d and replace with Poly1d ?

2009-09-28 Thread Charles R Harris
On Mon, Sep 28, 2009 at 2:59 PM, Robert Kern  wrote:

> On Mon, Sep 28, 2009 at 15:46, Charles R Harris
>  wrote:
>
> > The more basic problem here is making poly1d look like an array, which it
> > isn't. The array bit is an implementation detail and would be private in
> > C++. with an as_array method to retrieve the details if wanted.
>
> I'm pretty sure that it is an intentional public API and not an
> implementation detail. The __array__() method is not "making poly1d
> look like an array"; it is the standard name for such as_array()
> conversion methods.
>
>
Exactly, and that is why it is a design decision error. It *shouldn't* work
with as_array unless it is *an array*, which it isn't. Really

In [19]: sin(poly1d([1,2,3]))
Out[19]: array([ 0.84147098,  0.90929743,  0.14112001])

That makes no sense. On the other hand, it is difficult to make arrays of
poly1d, which does make sense because the polynomials are a commutative
ring.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Deprecate poly1d and replace with Poly1d ?

2009-09-28 Thread Robert Kern
On Mon, Sep 28, 2009 at 15:46, Charles R Harris
 wrote:

> The more basic problem here is making poly1d look like an array, which it
> isn't. The array bit is an implementation detail and would be private in
> C++. with an as_array method to retrieve the details if wanted.

I'm pretty sure that it is an intentional public API and not an
implementation detail. The __array__() method is not "making poly1d
look like an array"; it is the standard name for such as_array()
conversion methods.

-- 
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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Deprecate poly1d and replace with Poly1d ?

2009-09-28 Thread Charles R Harris
Because poly1d exports the __array__ interface, a design error IMHO that
makes it play badly with the prospective chebyshev module. For example the
following should convert from a Chebyshev series to a power series

chebval([1,0,0], poly1d(1,0))

and it does if I make sure to pass the poly1d as object in an array, but to
do that I have to check that it is an instance of poly1d and take special
measures. I shouldn't have to do that, it violates duck typing.

The more basic problem here is making poly1d look like an array, which it
isn't. The array bit is an implementation detail and would be private in
C++. with an as_array method to retrieve the details if wanted.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion