
Dear all, Is there a small bug in following? In [2]: b Out[2]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) In [3]: b.flatten(order='C') --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /mnt/f/<ipython console> in <module>() TypeError: flatten() takes no keyword arguments order='F' gave tha same. cheers, chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************

It works for me, which version of numpy are you using? What do you get when you type help(b.flatten)? -=- Olivier Le 5 avril 2012 04:45, Chao YUE <chaoyuejoy@gmail.com> a écrit :
Dear all,
Is there a small bug in following?
In [2]: b Out[2]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]])
In [3]: b.flatten(order='C') --------------------------------------------------------------------------- TypeError Traceback (most recent call last)
/mnt/f/<ipython console> in <module>()
TypeError: flatten() takes no keyword arguments
order='F' gave tha same.
cheers,
chao
--
*********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi, I use 1.51. In [69]: np.__version__ Out[69]: '1.5.1' the help information seems OK. In [70]: b.flatten? Type: builtin_function_or_method Base Class: <type 'builtin_function_or_method'> String Form: <built-in method flatten of numpy.ndarray object at 0xb5d4a58> Namespace: Interactive Docstring: a.flatten(order='C') Return a copy of the array collapsed into one dimension. Parameters ---------- order : {'C', 'F'}, optional Whether to flatten in C (row-major) or Fortran (column-major) order. The default is 'C'. Returns ------- y : ndarray A copy of the input array, flattened to one dimension. See Also -------- ravel : Return a flattened array. flat : A 1-D flat iterator over the array. Examples -------- >>> a = np.array([[1,2], [3,4]]) >>> a.flatten() array([1, 2, 3, 4]) >>> a.flatten('F') array([1, 3, 2, 4]) cheers, Chao 2012/4/5 Olivier Delalleau <shish@keba.be>
It works for me, which version of numpy are you using? What do you get when you type help(b.flatten)?
-=- Olivier
Le 5 avril 2012 04:45, Chao YUE <chaoyuejoy@gmail.com> a écrit :
Dear all,
Is there a small bug in following?
In [2]: b Out[2]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]])
In [3]: b.flatten(order='C')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last)
/mnt/f/<ipython console> in <module>()
TypeError: flatten() takes no keyword arguments
order='F' gave tha same.
cheers,
chao
--
*********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************

Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if it's a bug that's been fixed in 1.6. Try without the keyword argument (b.flatten('C')), see if at least that works. -=- Olivier Le 5 avril 2012 08:12, Chao YUE <chaoyuejoy@gmail.com> a écrit :
Hi,
I use 1.51. In [69]: np.__version__ Out[69]: '1.5.1'
the help information seems OK.
In [70]: b.flatten? Type: builtin_function_or_method Base Class: <type 'builtin_function_or_method'> String Form: <built-in method flatten of numpy.ndarray object at 0xb5d4a58> Namespace: Interactive Docstring: a.flatten(order='C')
Return a copy of the array collapsed into one dimension.
Parameters ---------- order : {'C', 'F'}, optional Whether to flatten in C (row-major) or Fortran (column-major) order. The default is 'C'.
Returns ------- y : ndarray A copy of the input array, flattened to one dimension.
See Also -------- ravel : Return a flattened array. flat : A 1-D flat iterator over the array.
Examples -------- >>> a = np.array([[1,2], [3,4]]) >>> a.flatten() array([1, 2, 3, 4]) >>> a.flatten('F') array([1, 3, 2, 4])
cheers,
Chao
2012/4/5 Olivier Delalleau <shish@keba.be>
It works for me, which version of numpy are you using? What do you get when you type help(b.flatten)?
-=- Olivier
Le 5 avril 2012 04:45, Chao YUE <chaoyuejoy@gmail.com> a écrit :
Dear all,
Is there a small bug in following?
In [2]: b Out[2]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]])
In [3]: b.flatten(order='C')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last)
/mnt/f/<ipython console> in <module>()
TypeError: flatten() takes no keyword arguments
order='F' gave tha same.
cheers,
chao
--
*********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
*********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi, Le 05/04/2012 15:00, Olivier Delalleau a écrit :
Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if it's a bug that's been fixed in 1.6. Try without the keyword argument (b.flatten('C')), see if at least that works.
I can reproduce Chao's bug with my numpy 1.5. As you've just suggested, it runs fine when there is no keyword. In [1]: a= np.arange(10) In [2]: a.flatten('C') # Works well Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) In [3]: a.flatten(order='C') # Chao's bug --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/pierre/<ipython-input-3-33cfe1eff84b> in <module>() ----> 1 a.flatten(order='C') TypeError: flatten() takes no keyword arguments In [4]: a.flatten? # indeed says there is a keyword order='C' In [5]: np.__version__ Out[5]: '1.5.1' Now if the bug is fixed in 1.6, there's nothing more to do than just wait for the update ! (Debian testing in my case) Best, Pierre

nice to know this. can also use b.transpose().flatten() to circumvent it. thanks, Chao 2012/4/5 Pierre Haessig <pierre.haessig@crans.org>
Hi,
Le 05/04/2012 15:00, Olivier Delalleau a écrit :
Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if it's a bug that's been fixed in 1.6. Try without the keyword argument (b.flatten('C')), see if at least that works.
I can reproduce Chao's bug with my numpy 1.5.
As you've just suggested, it runs fine when there is no keyword.
In [1]: a= np.arange(10)
In [2]: a.flatten('C') # Works well Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
In [3]: a.flatten(order='C') # Chao's bug --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/pierre/<ipython-input-3-33cfe1eff84b> in <module>() ----> 1 a.flatten(order='C')
TypeError: flatten() takes no keyword arguments
In [4]: a.flatten? # indeed says there is a keyword order='C'
In [5]: np.__version__ Out[5]: '1.5.1'
Now if the bug is fixed in 1.6, there's nothing more to do than just wait for the update ! (Debian testing in my case)
Best, Pierre
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************

Sorry for the noise on the ML, I thougt I had made a private reply... -- Pierre Le 05/04/2012 18:53, Pierre Haessig a écrit :
Hi Chao,
Le 05/04/2012 17:17, Chao YUE a écrit :
nice to know this. can also use b.transpose().flatten() to circumvent it. Just a short remark : b.T is a shorcut for b.transpose() ;-)
Best, Pierre
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
Chao YUE
-
Olivier Delalleau
-
Pierre Haessig