[Numpy-discussion] type and kind for custom dtypes
sebastian at sipsolutions.net
Sun May 5 12:54:16 EDT 2019
On Sun, 2019-05-05 at 11:03 -0400, Alex Samuel wrote:
> > On May 5, 2019, at 10:58, Alex Samuel <alex at alexsamuel.net> wrote:
> > Through trial and error, I've found that if I choose an unused type
> > code for each dtype, coercion seems to work as I expect it to (no
> > coercion unless I've provided a cast). The kind doesn't seem to
> > matter.
> Apologies, a correction: I mixed up kind and type above. I meant
> that I've found I need to choose distinct kinds for the coercion
> rules to treat my dtypes as distinct, rather than the type.
It is cool to here about interest in custom dtypes.
Numpy has the concept of "same-kind" casting, which may be what bites
you here? So you have unsafe casting, but because you pick the same
"kind" numpy thinks it is OK to do it in ufuncs? There may also be
issues surrounding 0-D arrays casting differently.
I honestly do not think there is any way to ensure you do not collide
with other kinds right now, but will check more closely tomorrow. I am
currently not even quite sure how the type code really interacts when
we have usertypes, and a bit surprised about what you describe.
We are now starting the progress of trying to improve the situation
with creating custom dtypes.
There will actually be discussions about this end of next week (in
Berkeley). But in any case I would be very interested in your specific
use-case and needs, and hopefully we can help you also on your end with
the current situation. We can discuss on the list, or get in contact
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: This is a digitally signed message part
More information about the NumPy-Discussion