+ 1

Who can explain this, I've read the documentation but i don't seem to understand. Thanks in advance

import numpy as np a = np.arange(16).reshape (4,4) a.flags Output C_CONTIGUOUS: True F_CONTIGUOUS: False OWNDATA: False WRITEABLE: True ALIGNED: True WRITEBACKIFCOPY: False UPDATEIFCOPY: False a = np.arange(16).reshape (4,4) b = a[:,1::2] b.flags Output C_CONTIGUOUS: False F_CONTIGUOUS: False OWNDATA: False WRITEABLE: True ALIGNED: True WRITEBACKIFCOPY: False UPDATEIFCOPY: False

22nd Jul 2019, 9:14 PM
Joseph Ojo
Joseph Ojo - avatar
8 odpowiedzi
+ 3
Ok, the np.arange(16) gives you a range of integers from 0 to 15. The reshape(4, 4) shapes the integers into a 4 by 4 matrix. I’m not sure about the flag method call, it looks like it deals with memory, anyone else know what the flags method means? The next section is nearly the same and mostly self- explanatory
22nd Jul 2019, 9:41 PM
Pete Cowling
Pete Cowling - avatar
+ 3
Tibor Santa thank you, that helped me and will probably help Femi Ojo
23rd Jul 2019, 11:44 AM
Pete Cowling
Pete Cowling - avatar
+ 2
Femi Ojo there is such a thing as contiguous and non-contiguous memory locations. My guess is that all 16 integers of the array are in contiguous locations for a, but b references non-contiguous locations. The C_ and F_ are throwing me for a loop though. I don’t know OWNDATA. WRITEABLE is obviously True because you can write it. I don’t want to guess wrong with ALIGNED. I think WRITEBACKIFCOPY and UPDATEIFCOPY may be talking about if they are modified when they are copied, like do they take on another value or stay the same. Sorry I can’t help for most of this
22nd Jul 2019, 10:41 PM
Pete Cowling
Pete Cowling - avatar
22nd Jul 2019, 9:18 PM
Joseph Ojo
Joseph Ojo - avatar
+ 1
Peter C... its what the C_CONTIGUOUS, F_CONTIGUOUS etc mean is what i really don't understand
22nd Jul 2019, 9:46 PM
Joseph Ojo
Joseph Ojo - avatar
+ 1
This one has a great explanation https://stackoverflow.com/questions/26998223/what-is-the-difference-between-contiguous-and-non-contiguous-arrays In short: contiguous means the array is stored in an unbroken block of memory. C-contiguous, as in 'C language' refers to the data organized row by row F-contiguous, as in 'Fortran language' means the array is organized column by column
23rd Jul 2019, 3:30 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Tibor Santa Thanks a lot for that, very informative, thanks to Peter C... too
23rd Jul 2019, 9:52 PM
Joseph Ojo
Joseph Ojo - avatar
0
Which language?
22nd Jul 2019, 9:15 PM
Francis Woli
Francis Woli - avatar