+ 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
8 Antworten
+ 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
+ 3
Tibor Santa thank you, that helped me and will probably help Femi Ojo
+ 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
+ 1
Peter C... its what the C_CONTIGUOUS, F_CONTIGUOUS etc mean is what i really don't understand
+ 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
+ 1
Tibor Santa Thanks a lot for that, very informative, thanks to Peter C... too
0
Which language?