[Numpy-discussion] A little help please?
Wed Feb 27 04:53:09 CST 2008
Travis E. Oliphant wrote:
> Neal Becker wrote:
>> My user-defined type project has mostly gone well, but I'm stuck on
>> mixed-type arithmetic.
>> I have 2 types: cmplx_int32 and cmplx_int64. I have added basic
>> arithmetic for those types, and for mix of those arrays and their
>> respective scalars. But mixed arithmetic only partly works
> This is an area that needs testing and possible fixes. The relevant
> code is in ufuncobject.c (select_types) and in multiarraymodule.c
> (PyArray_CanCoerceScalar). If you can go through that code you may be
> able to see what the problem is and let us know.
> I tried to support this kind of thing you are doing, but I'm not sure
> how well I succeeded because I didn't have time or the code to test it
> with. Thus, there is still some work to do.
> The fact that radd is not called is because ufuncs try to handle
> everything (the ufunc is more general than just the functions with "r"
> prefixes. I think one problem may be due to the fact that the first
> argument to a ufunc is the one that defines the search for the correctly
> registered function and there may be no code to allow other arguments to
> direct the search should that one fail.
> I'm actually pleased you've gotten this far. I'll keep trying to help
> as I get time.
The code for this is a bit hard to understand. It does appear that it only
searches for a conversion on the 2nd argument. I don't think that's
What I'm wondering is, this works fine for builtin types. What is different
in the handling of builtin types?
More information about the Numpy-discussion