From: Charles R H. <cha...@gm...> - 2006-09-05 16:40:58
|
I am trying to write more document strings for numpy and have a question about the order keyword in tostring. The usual allowed values of this keyword are "C", "F", or None, but in the tostring method there is also the value "Any" which has the same effect as None. I wonder if the "Any" shouldn't be removed as None seems to be the preferred form in other methods. Also, the default value of order in the tostring method is "C" and it seems to me that the principal of least surprise requires None as the default so that the order of the array being converted is the default. Chuck |
From: Charles R H. <cha...@gm...> - 2006-09-05 17:17:11
|
On 9/5/06, Charles R Harris <cha...@gm...> wrote: > > I am trying to write more document strings for numpy and have a question > about the order keyword in tostring. The usual allowed values of this > keyword are "C", "F", or None, but in the tostring method there is also the > value "Any" which has the same effect as None. I wonder if the "Any" > shouldn't be removed as None seems to be the preferred form in other > methods. Also, the default value of order in the tostring method is "C" and > it seems to me that the principal of least surprise requires None as the > default so that the order of the array being converted is the default. > > Chuck > > What is the actual order of data in memory? Is it always row major? In [38]: array([[1,2],[3,4]], dtype=int8, order="F").tofile('test.txt', sep=" ") In [39]: cat test.txt 1 2 3 4 In [40]: array([[1,2],[3,4]], dtype=int8, order="F").tostring(order="A") Out[40]: '\x01\x03\x02\x04' |
From: Travis O. <oli...@ie...> - 2006-09-05 17:43:17
|
Charles R Harris wrote: > I am trying to write more document strings for numpy and have a > question about the order keyword in tostring. The usual allowed values > of this keyword are "C", "F", or None, but in the tostring method > there is also the value "Any" which has the same effect as None. I > wonder if the "Any" shouldn't be removed as None seems to be the > preferred form in other methods. I don't think keeping 'Any' as a keyword here is a problem. > Also, the default value of order in the tostring method is "C" and it > seems to me that the principal of least surprise requires None as the > default so that the order of the array being converted is the default. I've thought this through several times. There may be a few cases where 'Any' is appropriate but the user will be expecting 'C' as the default because that was the only possibility for a long time. It's actually very problematic to switch to 'Any' as the default. You end up with lots of surprises as things start behaving very differently then they used to under Numeric once you transpose the array. -Travis |
From: Charles R H. <cha...@gm...> - 2006-09-05 18:37:31
|
On 9/5/06, Travis Oliphant <oli...@ie...> wrote: > > Charles R Harris wrote: > > I am trying to write more document strings for numpy and have a > > question about the order keyword in tostring. The usual allowed values > > of this keyword are "C", "F", or None, but in the tostring method > > there is also the value "Any" which has the same effect as None. I > > wonder if the "Any" shouldn't be removed as None seems to be the > > preferred form in other methods. > I don't think keeping 'Any' as a keyword here is a problem. Yeah, I noticed that the PyArray_OrderConverter just replaces None by "A" and is common to all the methods but the default is set in the calling code. > Also, the default value of order in the tostring method is "C" and it > > seems to me that the principal of least surprise requires None as the > > default so that the order of the array being converted is the default. > I've thought this through several times. There may be a few cases where > 'Any' is appropriate but the user will be expecting 'C' as the default > because that was the only possibility for a long time. It's actually > very problematic to switch to 'Any' as the default. You end up with > lots of surprises as things start behaving very differently then they > used to under Numeric once you transpose the array. > > -Travis Ok, I will add a comment to tofile that the data is written out in "C" order. Chuck |
From: Lisandro D. <da...@gm...> - 2006-09-05 18:33:11
|
BTW, in numpy-1.0b1 numpy.zeros((3,3), order=3D'QQQ') pass without generating any error... Is this intended behaviour? --=20 Lisandro Dalc=EDn --------------- Centro Internacional de M=E9todos Computacionales en Ingenier=EDa (CIMEC) Instituto de Desarrollo Tecnol=F3gico para la Industria Qu=EDmica (INTEC) Consejo Nacional de Investigaciones Cient=EDficas y T=E9cnicas (CONICET) PTLC - G=FCemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 |
From: Charles R H. <cha...@gm...> - 2006-09-05 18:40:51
|
On 9/5/06, Lisandro Dalcin <da...@gm...> wrote: > > BTW, in numpy-1.0b1 > > numpy.zeros((3,3), order='QQQ') > > pass without generating any error... Is this intended behaviour? This has been fixed: In [3]: zeros((3,3), order='QQQ') --------------------------------------------------------------------------- exceptions.TypeError Traceback (most recent call last) /home/charris/<ipython console> TypeError: order not understood Chuck |