[Numpy-discussion] A question about dtype syntax
Pierre GM
pgmdevlist@gmail....
Wed Aug 31 05:42:21 CDT 2011
On Aug 31, 2011, at 12:20 PM, Jean-Baptiste Marquette wrote:
>
> Hi Pierre,
>
> Thanks for the guess. Unfortunately, I got the same error:
>
> [('bs3000k.cat', 280.60341, -7.09118, 9480, 0.2057, 0.14)]
> Traceback (most recent call last):
> File "/Users/marquett/workspace/Distort/src/StatsSep.py", line 40, in <module>
> StatsAll = np.array(np.asarray(Stats), dtype=('a15, f8, f8, i4, f8, f8'))
> ValueError: could not convert string to float: bs3000k.cat
Of course, silly me
Your line 40 is actually
>>> StatsAll = np.array(np.asarray(Stats), dtype=('a15, f8, f8, i4, f8, f8'))
With np.asarray(Stats), you're trying to load Stats as an array using a dtype of float by default. Of course, np.asarray is choking on the first element.
So, try to use instead
>>> StatsAll = np.array(Stats, dtype=('a15, f8, f8, i4, f8, f8'))
More information about the NumPy-Discussion
mailing list