On Mon, Apr 21, 2008 at 9:09 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote:
> Charles R Harris wrote: > > > > > > On Mon, Apr 21, 2008 at 8:53 PM, Charles R Harris > > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > > > > > > > > On Mon, Apr 21, 2008 at 8:28 PM, Travis E. Oliphant > > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > > > > Charles R Harris wrote: > > > I've gotten my own python class with a logical_not method to > > work > > > correctly if I goto > > numpy/core/code_generators/generate_umath.py and > > > change > > I need more context for this. Why does the umath generator > > matter for > > your python class? > > > > > > 'logical_not' : > > > Ufunc(1, 1, None, > > > 'returns not x elementwise.', > > > TD(noobj, out='?'), > > > TD(M, f='logical_not', out='?'), > > > ), > > > > > > to > > > > > > 'logical_not' : > > > Ufunc(1, 1, None, > > > 'returns not x elementwise.', > > > TD(noobj, out='?'), > > > TD(M, f='logical_not'), > > > ), > > > > > Why is this an error? Is the difference only removing the out > > variable? It's been a while since I reviewed this code, so > > what does > > removing the out variable do functionally (What is the > > difference in the > > ufunc that is generated)? > > > > > > The way it is, it passes a boolean array to the PyUFunc_O_O_method > > loop where the loop is expecting an object array. I checked the > > step size to see this, and that's also how the generated signature > > reads. Consequently, when the reference count is decremented bad > > things happen. I suspect this hasn't been seen before because it > > hadn't been tried. I wrote loop tests before cleaning up the loop > > code and the bug turned up then. > > > > My guess is that here M means object called through non-Python > > method (logical_not), and omitting out means the output type is > > the same as the input. I suspect that '?' should do the same thing > > and that there might be a bug in the function dispatcher or the > > signature generator, but I'm not clear on that yet. > > > > > > If out is omitted, the output types matches the input types. Here's > > where the output types are generated: > > > > def finish_signature(self, nin, nout): > > if self.in_ is None: > > self.in_ = self.type * nin > > assert len(self.in_) == nin > > if self.out is None: > > self.out = self.type * nout > > assert len(self.out) == nout > > > > So that seems like the right thing to do. I still don't know what '?' > > means, though. > > Thanks Chuck, > > I get it now (I should have spent a minute looking at the code). The > '?' is the character code for "boolean" > > So, I think you are right about the bug. > OK, So I quess that everywhere I see TD(M... I should remove the "out='?' ". Will do. Chuck
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
