Hello Ask,
I bet this is because you are storing these as attrs...which will default
back to some pickled Python representation.
Can you check if this works as expected when saving as actual arrays.
Something like:
import numpy as np
import tables
with tables.openFile("test.h5", "w") as f:
A=np.array([[0,1],[2,3]])
a=f.createArray("/", "a", A)
b=f.createArray("/", "b", A.T.copy())
c=f.createArray("/", "c", A.T)
assert np.all(a==A)
assert np.all(b==A.T)
assert np.all(c==A) # AssertionError!
assert np.all(c==A.T)
Be Well
Anthony
On Wed, Aug 15, 2012 at 4:13 AM, Ask F. Jakobsen <a...@linet.dk> wrote:
> 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!
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Pytables-users mailing list
> Pytables-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pytables-users
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users