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

Reply via email to