[Numpy-discussion] how to find out element size of flexible dtype
Koert Kuipers
Koert.Kuipers at diamondnotch.com
Sun Oct 17 21:42:39 EDT 2010
Hello all,
If my function receives an array with a flexible dtype such as string or unicode, how do I find out what the size (max number of elements, not number of bytes) of the datatype is?
For example:
>>> x = np.array(['a', 'b', 'cd'], (np.unicode_, 4))
>>> x.dtype
dtype('<U4')
The string representation of x.dtype shows that is has element size 4, so I could get the element size by parsing that, but is there a more elegant way to get this?
Thanks,
Koert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20101017/305d95d6/attachment.html>
More information about the NumPy-Discussion
mailing list