<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>All:<BR> <BR>Say I have an array:<BR> <BR>a = (['rrrrggggbbbbaaaa'],['rrrrggggbbbbaaaa'])<BR> <BR>How do I make it so that I now have:<BR> <BR>starting with first element (a[0])<BR>new_arr[0] = 'r'<BR>new_arr[1] = 'g'<BR>new_arr[2] = 'b'<BR>new_arr[3] = 'a'<BR>new_arr[4] = 'r'<BR>.....<BR> <BR>continuing "through" a[1] with the same new_arr<BR>new_arr[N] = 'r'<BR>new_arr[N+1] = 'g'<BR>....<BR> <BR>-M<BR><BR><BR><BR><BR>
<BLOCKQUOTE>
<HR id=EC_stopSpelling>
From: marlin_rowley@hotmail.com<BR>To: robert.kern@gmail.com; python-list@python.org<BR>Subject: RE: numpy.frombuffer != unpack() ??<BR>Date: Fri, 16 May 2008 17:31:30 -0500<BR><BR>
<META content="Microsoft SafeHTML" name=Generator>
<STYLE>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass body.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
Thank you! That solved it!<BR> <BR>-M<BR><BR><BR>
<HR id=EC_stopSpelling>
<BR>> To: python-list@python.org<BR>> From: robert.kern@gmail.com<BR>> Subject: Re: numpy.frombuffer != unpack() ??<BR>> Date: Fri, 16 May 2008 17:25:00 -0500<BR>> <BR>> Marlin Rowley wrote:<BR>> > All:<BR>> > <BR>> > I'm getting different floating point values when I use numpy vs. unpack().<BR>> > <BR>> > frgba = numpy.frombuffer(<string of bytes>, dtype=float32)<BR>> > buffer = unpack("!f", byte)<BR>> > <BR>> > frgba[0] != buffer[0]<BR>> > <BR>> > why? This is forcing me use the unpack() function since it's giving me <BR>> > the correct values. What am I doing wrong?<BR>> <BR>> Endianness, perhaps? '!' specifies big-endian data (an alias for '>'). Most <BR>> likely, you are on a little-endian platform. All of the dtypes in numpy default <BR>> to the native-endianness unless specified. If you want to read big-endian data <BR>> using numpy, do this:<BR>> <BR>> frgba = numpy.frombuffer(<string of bytes>, dtype='>f')<BR>> <BR>> If you have any more problems with numpy, please join us on the numpy mailing <BR>> list. When reporting problems, please try to provide a small but complete <BR>> snippet of self-contained code, the output that you got, and explain the output <BR>> that you expected to get. Thank you.<BR>> <BR>> http://www.scipy.org/Mailing_Lists<BR>> <BR>> -- <BR>> Robert Kern<BR>> <BR>> "I have come to believe that the whole world is an enigma, a harmless enigma<BR>> that is made terrible by our own mad attempt to interpret it as though it had<BR>> an underlying truth."<BR>> -- Umberto Eco<BR>> <BR>> --<BR>> http://mail.python.org/mailman/listinfo/python-list<BR><BR><BR>
<HR>
E-mail for the greater good. <A href="http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ GreaterGood" target=_blank>Join the i’m Initiative from Microsoft.</A> </BLOCKQUOTE><br /><hr />E-mail for the greater good. <a href='http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ GreaterGood' target='_new'>Join the i’m Initiative from Microsoft.</a></body>
</html>