[Numpy-discussion] Automatic custom dtype

Richard Hattersley rhattersley@gmail....
Fri Jun 28 14:11:30 CDT 2013


On 28 June 2013 17:33, Charles R Harris <charlesr.harris@gmail.com> wrote:
> On Fri, Jun 28, 2013 at 5:27 AM, Richard Hattersley <rhattersley@gmail.com>
> wrote:
>> So:
>>     np.array([scalar]) => np.array([scalar], dtype=my_dtype)
>> But:
>>     np.array(scalar) => np.array(scalar, dtype=object)
>
> So the scalar case (0 dimensional array) doesn't work right. Hmm, what
> happens when you index the first array? Does subclassing the generic type
> work in 1.6?

Indexing into the first array works fine. So something like `a[0]`
calls my_dtype->f->getitem which creates a new scalar instance, and
something like `a[:1]` creates a new view with the correct dtype.


> My impression is that subclassing the generic type should be required, but I
> don't see where it is documented :(

Can you elaborate on why the generic type should be required? Do you
think it might cause problems elsewhere? (FYI I've also tested with a
patched version of v1.6.2 which fixes the typo which prevents the use
of user-defined dtypes with ufuncs, and that functionality seems to
work fine too.)


> Anyway, what is the problem with the
> third party code? Is there no chance that you can get hold of it to fix it?

Unfortunately it's out of my control.


Regards,
Richard


More information about the NumPy-Discussion mailing list