[Numpy-discussion] Seg fault from numpy.rec.fromarrays
Charles R Harris
charlesr.harris@gmail....
Tue Mar 24 19:41:45 CDT 2009
2009/3/24 Dan Yamins <dyamins@gmail.com>
> Hi all,
>
> I'm having a seg fault error from numpy.rec.fromarrays.
>
> I have a python list
> L = [Col1, Col2]
> where Col1 and Col2 are python lists of short strings (the max length of
> Col1 strings is 4 chars and max length of Col2 is 7 chars). The len of Col1
> and Col2 is about 11500.
>
> Then I attempt
> >>> A = numpy.rec.fromarrays(L,names = ['Aggregates','__color__'])
>
> This should produce a numpy record array with two columns, one called
> 'Aggregates', the other called '__color__'.
>
> In and of it self, this runs. But then when I attempt to look at the
> contents of A, running the __getitem__ method, say by doing:
>
> >>> print A
> or
> >>> A.tolist()
> or
> >>> A[0]
>
> then I get a seg fault error. (Acutally, the segfault only occurs about
> 80% of the time I run these commands.)
>
> However, the __getitem__ method does work to produce attribute arrays from
> column names , e.g.
>
> >>> Ag = A['Aggregates']
>
> or
>
> >>> col = A['__color__']
>
> both produce (apparently) completely correct and working numpy arrays.
>
> Moreover, If I pickle the object A before looking at it, everything works
> fine. E.g. if I execute:
>
> >>> Hold_A = A.dumps()
> >>> A = numpy.loads(Hold_A)
>
> then A seems to work fine.
>
> (Also: pickling the list L = [Col1,Col2] first, before running the
> numpy.rec.fromarrays method, does not always fix the segfault.)
>
>
> Can someone explain why this might be happening, and how I can fix it
> (without having to use the pickling hack)?
>
What architecture/operating system is this?
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090324/1a1cfdbd/attachment.html
More information about the Numpy-discussion
mailing list