[Numpy-discussion] vacuum expansion of strings in record array

Todd Miller jmiller at stsci.edu
Sun Jun 5 07:15:04 CDT 2005


On Sat, 2005-06-04 at 14:56 -0400, Les Schaffer wrote:
> is this a feature or a bug? see snippet below, i would like the empty 
> string to stay empty, not grow to an empty space from nothing.

This is a subtle quirk that it would be nice to be without but not an
accident or bug.  It's an intentional feature since if conforms to the
FITS file format which motivated the development of records.py to begin
with.  I think there probably should be a less eclectic subclass of
RawCharArray,  but don't have the time to write it myself.

Regards,
Todd

> thnx
> 
> les schaffer
> 
> 
> code:
> 
> import numarray.records as rec
> 
> names = ['col1', 'col2']
> 
> d1 = [ ['', 'hello'], ['', 'world']]
> d2 = [ ['hh', 'hello'], ['', 'world']]
> print d1, d2
> 
> recarray1 = rec.array(d1, names=names)  # aligned=0,1 made no diff
> recarray2 = rec.array(d2, names=names)  # aligned=0,1 made no diff
> print recarray1
> print recarray2
> 
> 
> output:
> 
> [['', 'hello'], ['', 'world']] [['hh', 'hello'], ['', 'world']]
> RecArray[
> ('', 'hello'),
> ('', 'world')
> ]
> RecArray[
> ('hh', 'hello'),
> (' ', 'world')
> 
>   ^
>   |____ vacuum expansion
> ]
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
> a projector? How fast can you ride your desk chair down the office luge track?
> If you want to score the big prize, get to know the little guy.  
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion





More information about the Numpy-discussion mailing list