[Numpy-discussion] Type checking of arrays containing strings

Arnar Flatberg arnar.flatberg@gmail....
Fri Jul 18 06:02:55 CDT 2008


On Fri, Jul 18, 2008 at 12:38 PM, Arnar Flatberg <arnar.flatberg@gmail.com>
wrote:

>
>
> On Fri, Jul 18, 2008 at 11:40 AM, Stéfan van der Walt <stefan@sun.ac.za>
> wrote:
>
>> 2008/7/18 Arnar Flatberg <arnar.flatberg@gmail.com>:
>> > I need to check if my array (a) is of type `string`. That is, I dont
>> know
>> > the number of characters beforehand, so I cant do a.dtype == '|S*' (* =
>> > (max) number of characters)
>> > Looking at my options,  I see either a.dtype.kind == 'S' or a.dtype.type
>> ==
>> > np.string_, might be ok. Are these any of the preffered ways, or is
>> there
>> > some other way?
>>
>> Maybe
>>
>> np.issubdtype(x.dtype, str)
>
> Yes, silly of me. I didnt look at the documentation (source) and tried
> np.issubdtype(x, str) as my first try. That not working, I got lost. That
> said, I think some other parameter names than arg1, arg2 would be nice for
> an undocumented function .
>
> Arnar
>
>  ... and instead of just complaining, I can do something about it :-) Could
you add permissions to me for the documentation editor, username:
ArnarFlatberg.

Thanks,

Arnar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080718/2cf85dca/attachment.html 


More information about the Numpy-discussion mailing list