Hi Jan,
A Thursday 13 September 2007, Jan Strube escrigué:
> Hello, list,
>
> I'm trying to read a couple of entries from a table.
> I'm on an intel MacBook using pytables 2 with python 2.5 and numpy
> 1.0.3. The problem is that I pass a numpy array to readCoordinates.
> That gives me the error message at the end of this mail.
> casting this array to a python list, however, lets me successfully
> read all the entries in the table. The dtype of the numpy array is
> int64, and the shape is (x,).
> numpy.all(entries == list(entries)) is True, so I really don't know
> where this difference in behavior comes from.
> I have not seen this before and I'm a bit surprised by this behavior.
Hmmm, based on your description I think that the guilty might be that
your numpy array is not contiguous, and PyTables don't check for that.
Please apply the attached patch and tell me whether it cures the
problem or not.
Cheers,
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
Index: tables/table.py
===================================================================
--- tables/table.py (revision 3245)
+++ tables/table.py (working copy)
@@ -1533,8 +1533,11 @@
if ncoords > 0:
# Turn coords into an array of 64-bit indexes, if necessary
if not (type(coords) is numpy.ndarray and
- coords.dtype.type is numpy.int64):
- coords = numpy.asarray(coords, dtype=numpy.int64)
+ coords.dtype.type is numpy.int64 and
+ coords.flags.contiguous and
+ coords.flags.aligned):
+ # Get a contiguous int64 array
+ coords = numpy.array(coords, dtype=numpy.int64)
self._read_elements(result, coords)
# Do the final conversions, if needed
@@ -1546,6 +1549,7 @@
result = self._getemptyarray(self.coldtypes[field])
return result
+
def readCoordinates(self, coords, field=None):
"""
Get a set of rows given their indexes as a (record) array.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users