From: Ask F. J. <as...@li...> - 2012-08-15 09:30:29
|
Hey all, When I store a view of a numpy array as an attribute it appears to be stored as the array that owns the data. Is this a bug? I find it confusing that the user has to check if the numpy array owns the data or always remember to do a copy() before storing a numpy array as an attribute. Below is some sample code that highlights the problem. Best regards, Ask import numpy as np import tables with tables.openFile("test.h5", "w") as f: x=f.createArray("/", "test", [0]) A=np.array([[0,1],[2,3]]) x.attrs['a']=A x.attrs['b']=A.T.copy() x.attrs['c']=A.T assert np.all(x.attrs['a']==A) assert np.all(x.attrs['b']==A.T) assert np.all(x.attrs['c']==A) assert np.all(x.attrs['c']==A.T) # AssertionError! |