[Numpy-discussion] Padding policy in CharArrays
Todd Miller
jmiller at stsci.edu
Thu Jan 6 14:40:01 EST 2005
In some kind of cosmic irony, your bona-fide-patch was filed as Junk
Mail by my filter. Anyway, thanks, it's committed in CVS. I added the
extra code to handle the PadAll case you flagged as "to be corrected."
Regards,
Todd
On Thu, 2005-01-06 at 12:53, Francesc Altet wrote:
> A Dilluns 03 Gener 2005 22:25, Francesc Altet va escriure:
> > Mmm, perhaps having the possibility to select the pad value in CharArray
> > creation time would be nice.
>
> I've ended making an implementation of this in numarray. With the patches
> (against numarray 1.1.1) I'm attaching, the next works:
>
> >>> b=strings.array(['0'], itemsize = 4, padc="\x00")
> >>> b.raw()
> RawCharArray(['0\x00\x00\x00'])
> >>> b.raw() >= '0\x00\x00\x00\x01'
> array([0], type=Bool)
>
> While the actual behaviour in numarray 1.1.1 is:
>
> >>> b=strings.array(['0'], itemsize = 4)
> >>> b.raw()
> RawCharArray(['0 '])
> >>> b.raw() >= '0\x00\x00\x00\x01'
> array([1], type=Bool)
>
> As you may have already noted, I've added a new parameter named padc to the
> CharArray/RawCharArray constructor being the default pad character value the
> space (" "), for backward compatibility. All the current tests for CharArray
> passes with patch applied.
>
> The new functionality is restricted to what I needed, but I guess it should
> be easily extended to be completely consistent in other cases. Feel free to
> add the patch to numarray if you feel it to be appropriate.
>
> Cheers,
--
More information about the NumPy-Discussion
mailing list