Am Mi 23 Jan 2013 16:57:27 CET schrieb Anthony Scopatz: > Hi Andreas, > > I think that the problem here is that coord_slice is actually a list > of slices, which you can't index by. (Though, you may be able to in > numpy...) > > Try something like _ds[coord_slice[0]] instead. > > Be Well > Anthony > > B eW > > > > On Tue, Jan 22, 2013 at 8:44 AM, Andreas Hilboll <li...@hilboll.de > <mailto:li...@hilboll.de>> wrote: > > Hi, > > how can I use Python's built-in `slice` object on CArray? > Currently, I'm > trying > > In: coord_slice > Out: [slice(0, 31, None), slice(0, 5760, None), slice(0, 2880, > None)] > > In: _ds > Out: /data/mydata (CArray(31, 5760, 2880), shuffle, blosc(5)) '' > atom := Float32Atom(shape=(), dflt=0.0) > maindim := 0 > flavor := 'numpy' > byteorder := 'little' > chunkshape := (1, 45, 2880) > > In: _ds[coord_slice] > Out: *** TypeError: long() argument must be a string or a number, > not 'slice' > > The problem is that I want to write something generic, and I don't > know > beforehand how many dimensions the CArray has. My current plan is to > create a tuple of slice objects programatically (using list > comprehension), and then use this tuple as index. But apparently it > doesn't work with pytables 2.3.1. > > Any suggestions on how to accomplish my task are greatly > appreciated :) > > Cheers, Andreas. > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET <http://ASP.NET>, > C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills > current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnnow-d2d > _______________________________________________ > Pytables-users mailing list > Pytables-users@lists.sourceforge.net > <mailto:Pytables-users@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/pytables-users > > > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnnow-d2d > > > _______________________________________________ > Pytables-users mailing list > Pytables-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pytables-users
Hi Anthony, thanks for your input. However, I need to slice in multiple dimensions simultaneously, because my array is very large and I don't want to clog memory. However, I found out that it works with a tuple of slice objects, so _ds[tuple(coord_slice)] works as expected. Cheers, Andreas. ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users