From: Alvaro T. C. <al...@mi...> - 2012-05-01 08:52:13
|
Ok, I think I know what happened: during interactive manipulation, at some point I must have forgotten adding '[:]' to assign to the column, i.e. mytable.cols.mycolumn = somearray instead of mytable.cols.mycolumn[:] = somearray This is related to https://github.com/PyTables/PyTables/issues/145 In-memory assignments can shadow access to the object in the file. IMHO this should not be allowed (in, fact, why not making the first assignment behave like the second?). -á. On Mon, Apr 30, 2012 at 20:24, Alvaro Tejero Cantero <al...@mi...> wrote: > I am now on another computer (no access to the one where I reported > the problem until tomorrow; uses 2.3.1 AFAIK) and here I have the > expected behaviour (2.3.1, as well). I hope that I made a mistake; > will update tomorrow. > > > -á. > > > On Mon, Apr 30, 2012 at 20:09, Francesc Alted <fa...@py...> wrote: >> On 4/30/12 12:08 PM, Alvaro Tejero Cantero wrote: >>> Hi all, >>> >>> I created a table: >>> >>>>>> joins.createTable('/','spikes',{'t20k':pt.Int32Col(),'tetrode':pt.UInt8Col(), 'unit':pt.UInt8Col()},'Spike times') >>> I populated it >>> >>>>>> joins.root.spikes.append(zip(np.arange(100),np.zeros(100), 3*np.ones(100))) >>> now if I do >>> >>>>>> joins.root.spikes.cols.tetrode[:] = np.ones(100) >>> I can see the updated value (all ones instead of zeros) >>> >>> If I fetch all the table in memory, >>> >>>>>> joins.root.spikes[:] >>> I still see only the original zeros, i.e. the column update has not propagated >> >> Hmm, I cannot reproduce this: >> >> In [18]: joins = pt.openFile("joins.h5", "w") >> >> In [19]: >> joins.createTable('/','spikes',{'t20k':pt.Int32Col(),'tetrode':pt.UInt8Col(), >> 'unit':pt.UInt8Col()},'Spike times') >> Out[19]: >> /spikes (Table(0,)) 'Spike times' >> description := { >> "t20k": Int32Col(shape=(), dflt=0, pos=0), >> "tetrode": UInt8Col(shape=(), dflt=0, pos=1), >> "unit": UInt8Col(shape=(), dflt=0, pos=2)} >> byteorder := 'little' >> chunkshape := (10922,) >> >> In [20]: joins.root.spikes.append(zip(np.arange(10),np.zeros(10), >> 3*np.ones(10))) >> >> In [22]: joins.root.spikes[:] >> Out[22]: >> array([(0, 0, 3), (1, 0, 3), (2, 0, 3), (3, 0, 3), (4, 0, 3), (5, 0, 3), >> (6, 0, 3), (7, 0, 3), (8, 0, 3), (9, 0, 3)], >> dtype=[('t20k', '<i4'), ('tetrode', 'u1'), ('unit', 'u1')]) >> >> In [23]: joins.root.spikes.cols.tetrode[:] = np.ones(10) >> >> In [24]: joins.root.spikes[:] >> Out[24]: >> array([(0, 1, 3), (1, 1, 3), (2, 1, 3), (3, 1, 3), (4, 1, 3), (5, 1, 3), >> (6, 1, 3), (7, 1, 3), (8, 1, 3), (9, 1, 3)], >> dtype=[('t20k', '<i4'), ('tetrode', 'u1'), ('unit', 'u1')]) >> >> Which versions are you using? >> >> -- >> Francesc Alted >> >> >> ------------------------------------------------------------------------------ >> 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 >> Pyt...@li... >> https://lists.sourceforge.net/lists/listinfo/pytables-users |