[Numpy-discussion] My identity

David Goldsmith d_l_goldsmith@yahoo....
Mon Jul 20 15:11:01 CDT 2009


Just to be clear, in which namespace(s) are we talking about making (or having made) the change: IIUC, the result you're talking about would be inappropriate for ufunc.identity.

DG

--- On Mon, 7/20/09, Keith Goodman <kwgoodman@gmail.com> wrote:

> From: Keith Goodman <kwgoodman@gmail.com>
> Subject: Re: [Numpy-discussion] My identity
> To: "Discussion of Numerical Python" <numpy-discussion@scipy.org>
> Date: Monday, July 20, 2009, 11:17 AM
> On Mon, Jul 20, 2009 at 10:53 AM,
> Pauli Virtanen<pav+sp@iki.fi> wrote:
> > On 2009-07-20, Keith Goodman <kwgoodman@gmail.com>
> wrote:
> > [clip]
> >> Oh, sorry, I misunderstood. Yes, a similar change
> was made to eye but
> >> not to identity.
> >
> > Nasty, duplicated code there it seems...
> 
> So
> 
> def myidentity2(n, dtype=None):
>     return eye(n, M=n, k=0, dtype=dtype)
> 
> >> timeit myidentity(10)
> 100000 loops, best of 3: 7.15 µs per loop
> >> timeit eye(10)
> 100000 loops, best of 3: 8.42 µs per loop
> >> timeit myidentity2(10)
> 100000 loops, best of 3: 9 µs per loop
> 
> There also a second identity in np.matlib that has its own
> code. That
> could be changed to
> 
> def myidentity2_matlib(n, dtype=None):
>     return asmatrix(eye(n, M=n, k=0,
> dtype=dtype))
> 
> or
> 
> def myidentity2_matlib(n, dtype=None):
>     return asmatrix(myidentity2(n, dtype))
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 


      


More information about the NumPy-Discussion mailing list