[Numpy-discussion] chararray behavior
Alan McIntyre
alan.mcintyre at gmail.com
Mon Jul 7 23:44:32 EDT 2008
Since chararray doesn't currently have any tests, I'm writing some,
and I ran across a couple of things that didn't make sense to me:
1. The code for __mul__ is exactly the same as that for __rmul__; is
there any reason __rmul__ shouldn't just call __mul__?
1.5. __radd__ seems like it doesn't do anything fundamentally
different from __add__, is there a reason to have a separate
implementation of __radd__?
2. The behavior of __mul__ seems odd:
>>> Q=np.chararray((2,2),itemsize=1,buffer='abcd')
>>> Q
chararray([['a', 'b'],
['c', 'd']],
dtype='|S1')
>>> Q*3
chararray([['aaa', 'bbb'],
['ccc', 'ddd']],
dtype='|S4')
>>> Q*4
chararray([['aaaa', 'bbbb'],
['cccc', 'dddd']],
dtype='|S4')
>>> Q*5
chararray([['aaaa', 'bbbb'],
['cccc', 'dddd']],
dtype='|S4')
Is it supposed to work this way?
Thanks,
Alan
More information about the NumPy-Discussion
mailing list