Re: [Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-03-06 Thread Charles R Harris
On Tue, Mar 1, 2011 at 8:51 AM, Wes McKinney wrote: > On Mon, Feb 28, 2011 at 10:52 PM, Wes McKinney > wrote: > > On Mon, Feb 28, 2011 at 7:24 PM, Pierre GM wrote: > >> > >> On Mar 1, 2011, at 1:05 AM, Bruce Southey wrote: > >> > >>> On Mon, Feb 28, 2011 at 4:52 PM, Wes McKinney > wrote: > >>>

Re: [Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-03-01 Thread Wes McKinney
On Mon, Feb 28, 2011 at 10:52 PM, Wes McKinney wrote: > On Mon, Feb 28, 2011 at 7:24 PM, Pierre GM wrote: >> >> On Mar 1, 2011, at 1:05 AM, Bruce Southey wrote: >> >>> On Mon, Feb 28, 2011 at 4:52 PM, Wes McKinney wrote: I'm having some trouble with the zeros_like function via np.fix:

Re: [Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-02-28 Thread Wes McKinney
On Mon, Feb 28, 2011 at 7:24 PM, Pierre GM wrote: > > On Mar 1, 2011, at 1:05 AM, Bruce Southey wrote: > >> On Mon, Feb 28, 2011 at 4:52 PM, Wes McKinney wrote: >>> I'm having some trouble with the zeros_like function via np.fix: >>> >>> def zeros_like(a): >>>    if isinstance(a, ndarray): >>>  

Re: [Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-02-28 Thread Pierre GM
On Mar 1, 2011, at 1:05 AM, Bruce Southey wrote: > On Mon, Feb 28, 2011 at 4:52 PM, Wes McKinney wrote: >> I'm having some trouble with the zeros_like function via np.fix: >> >> def zeros_like(a): >>if isinstance(a, ndarray): >>res = ndarray.__new__(type(a), a.shape, a.dtype, order=

Re: [Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-02-28 Thread Bruce Southey
On Mon, Feb 28, 2011 at 4:52 PM, Wes McKinney wrote: > I'm having some trouble with the zeros_like function via np.fix: > > def zeros_like(a): >    if isinstance(a, ndarray): >        res = ndarray.__new__(type(a), a.shape, a.dtype, order=a.flags.fnc) >        res.fill(0) >        return res >    

[Numpy-discussion] {zeros, empty, ...}_like functions behavior with subclasses

2011-02-28 Thread Wes McKinney
I'm having some trouble with the zeros_like function via np.fix: def zeros_like(a): if isinstance(a, ndarray): res = ndarray.__new__(type(a), a.shape, a.dtype, order=a.flags.fnc) res.fill(0) return res try: wrap = a.__array_wrap__ except AttributeError: