On Mon, Jul 10, 2017 at 8:46 AM Yarko Tymciurak <yark...@gmail.com> wrote:
> On Mon, Jul 10, 2017 at 8:37 AM <paul.carr...@free.fr> wrote: > >> Thanks >> >> >> Nevertheless it does not work for me and I suspect the python/numpy >> releases :-( >> >> The server on which I'm working on is under Contos 7 that uses python 2.7 >> et numpy 1.7 from memory ; I tried to upgrade both of them (plus spyder) >> but it fails. >> > Question: Did you try to control the python & numpy versions by creating a virtualenv, or a conda env? I didn't want to impact the other solvers installed on, so I stopped >> >> Paul >> >> a = np.arange(40).reshape(5, 8); print(a) >> print("b =") >> b = np.lib.stride_tricks.as_strided(a, (2, 5, 4), (16, 32, 4)); print(b) >> >> [[ 0 1 2 3 4 5 6 7] >> [ 8 9 10 11 12 13 14 15] >> [16 17 18 19 20 21 22 23] >> [24 25 26 27 28 29 30 31] >> [32 33 34 35 36 37 38 39]] >> b = >> [[[ 0 4294967296 1 8589934592] >> [ 4 21474836480 5 25769803776] >> [ 8 38654705664 9 42949672960] >> [ 12 55834574848 13 60129542144] >> [ 16 73014444032 17 77309411328]] >> >> [[ 2 12884901888 3 17179869184] >> [ 6 30064771072 7 34359738368] >> [ 10 47244640256 11 51539607552] >> [ 14 64424509440 15 68719476736] >> [ 18 81604378624 19 85899345920]]] >> >> >> >> >> Le 2017-07-10 15:16, eat a écrit : >> >> Hi, >> >> On Mon, Jul 10, 2017 at 3:20 PM, <paul.carr...@free.fr> wrote: >> >>> Dear All >>> >>> I'm looking in a way to reshape a 2D matrix into a 3D one ; in my >>> example I want to *move the columns from the 4th to the 8th in the 2nd >>> plane* (3rd dimension i guess) >>> >>> a = np.random.rand(5,8); print(a) >>> >>> I tried >>> >>> a = p.reshape(d, (2,5,4), ) but it is not what I'm expecting >>> >>> >>> Nota : it looks like the following task (while I want to split it in 2 >>> levels and not in 4), but I've not understood at all >>> >>> >>> https://stackoverflow.com/questions/31686989/numpy-reshape-and-partition-2d-array-to-3d >>> >> Is this what you are looking for: >> import numpy as np >> >> a= np.arange(40).reshape(5, 8) >> >> a >> Out[]: >> 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], >> [24, 25, 26, 27, 28, 29, 30, 31], >> [32, 33, 34, 35, 36, 37, 38, 39]]) >> >> np.lib.stride_tricks.as_strided(a, (2, 5, 4), (16, 32, 4)) >> Out[]: >> array([[[ 0, 1, 2, 3], >> [ 8, 9, 10, 11], >> [16, 17, 18, 19], >> [24, 25, 26, 27], >> [32, 33, 34, 35]], >> >> [[ 4, 5, 6, 7], >> [12, 13, 14, 15], >> [20, 21, 22, 23], >> [28, 29, 30, 31], >> [36, 37, 38, 39]]]) >> >> Regards, >> -eat >> >>> >>> Thanks for your support >>> >>> >>> Paul >>> >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@python.org >>> https://mail.python.org/mailman/listinfo/numpy-discussion >>> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@python.org >> https://mail.python.org/mailman/listinfo/numpy-discussion >> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@python.org >> https://mail.python.org/mailman/listinfo/numpy-discussion >> >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion