On Wed, Dec 30, 2009 at 10:20 AM, Matthew Brett <[email protected]> wrote: > Hi, > >> x = "¥00" >> arr = np.array([x]) >> lst = [x] >> >> arr[0] == x # False >> arr[0] == "" # True >> >> lst[0] == x # True >> lst[0] == "" # False > > Ah - thanks - got it. > >>> It looks to me as though the >>> buffer contents of [''] is a length 1 string with a 0 byte, and an >>> array.size of 1 - is that also what you think? I guess I think that >>> it should be a length 0 string, with a array.size of 0 >> >> Array size of 0 would be very weird: it means it would have no items, >> whereas it actually has one item (which itself has a size 0). > > Is this a string-specific thing?
No. I was not very clear: My point was that size 0 array is likely not what you want. What you want is arrays whose *itemsize" is 0. > I mean, you can have size 0 1d > numeric arrays. Sorry if I'm being slow, it's late here. > > In [70]: np.array([[]]).shape > Out[70]: (1, 0) > > In [71]: np.array([[]]).size > Out[71]: 0 Yes, you can create array with size 0. But I don't think that's what you want - you cannot index them normally (even though the array is 2d, you cannot do arr[0][0], so I don't think that's very useful for your case). David _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
