As a result, an array of continuous numbers C is created:
import numpy a = numpy.ones((1024,1024,5))
Now, if I chop it, the result may not be the same. For example:
bn = a[:, :, n]
with n from 0 to 4. My problem is that I need bn be C-adjacent and I need to do this for many instances of a. I just need every bn once and you want to avoid
bn = bn.copy(order='C')
I also do not want to rewrite my code in such a way that
a = numpy.ones((5,1024,1024))
Is there a faster and cheaper way to get bn than to make a copy?
Background:
I want to hash each fragment of each a using
import hashlib hashlib.sha1(a[:, :, n]).hexdigest()
Unfortunately, this will raise a ValueError , complaining about the order. Therefore, if there is another quick way to get the hash that I want, I would use it too.
python arrays numpy
Daniel Sk
source share