Travis E. Oliphant wrote:
> Neal Becker wrote:
>> In arrayobject.c, various complex functions (e.g., array_imag_get) use:
>> PyArray_ISCOMPLEX -> PyTypeNum_ISCOMPLEX,
>> which is hard coded to 2 predefined types :(
>>
>> If PyArray_ISCOMPLEX allowed user-defined types, I'm guessing functions
>> such as array_imag_get would just work?
>>
> I don't think that it true. There would need to be some kind of idea
> of "complex-ness" that is tested. One way this could work is if your
> corresponding scalar inherited from the generic complex scalar type and
> then that was tested for.
>
> -Travis O.
One thing that isn't working (so far) is fill:
In [47]: a = array ([cmplx_int32(e) for e in xrange (10)])
In [48]: a
Out[48]: array([(0,0), (1,0), (2,0), (3,0), (4,0), (5,0), (6,0), (7,0), (8,0),
(9,0)], dtype=cmplx_int32)
In [49]: r = get_real (a)
In [50]: r
Out[50]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32)
In [51]: r[:] = 7
In [52]: a
Out[52]: array([(7,0), (7,0), (7,0), (7,0), (7,0), (7,0), (7,0), (7,0), (7,0),
(7,0)], dtype=cmplx_int32)
In [53]: r.fill(8)
In [54]: a
Out[54]: array([(8,8), (8,8), (8,8), (8,8), (8,8), (7,0), (7,0), (7,0), (7,0),
(7,0)], dtype=cmplx_int32)
In [55]: r
Out[55]: array([8, 8, 8, 8, 8, 7, 7, 7, 7, 7], dtype=int32)
As you can see, fill only filled 1/2 of the array. slice [:] worked OK.
My get_real is pretty much copied from real:
ret = (PyArrayObject *) \
PyArray_NewFromDescr(self->ob_type,
ret_type,
self->nd,
self->dimensions,
self->strides,
self->data + offset,
self->flags, (PyObject *)self);
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion