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
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
BTW, in numpy-1.0b1 numpy.zeros((3,3), order='QQQ') pass without generating any error... Is this intended behaviour? -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594
On 9/5/06, Lisandro Dalcin
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
On 9/5/06, Travis Oliphant
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
On 9/5/06, Charles R Harris
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'
participants (3)
-
Charles R Harris
-
Lisandro Dalcin
-
Travis Oliphant