In NumPy, why hstack()copy data from arrays that are stacked:
A, B = np.array([1,2]), np.array([3,4])
C = np.hstack((A,B))
A[0]=99
gives for C:
array([1, 2, 3, 4])
whereas it hsplit()creates a data view:
a = np.array(((1,2),(3,4)))
b, c = np.hsplit(a,2)
a[0][0]=99
gives for b:
array([[99],
[ 3]])
I mean - what is the reason for the implementation of this behavior (which I find inconsistent and difficult to remember): I agree that this happens because it is encoded in this way ...
source
share