开发者

Updating a quickhull implementation to Python 3.2, list manipulation

So, I've got a quickhull implementation in python that I'm trying to use in python 3.2. Mostly it's fine, but there's a list indexing problem I'm havin开发者_如何学JAVAg. The code does:

axis = sample[:,0]

This doesn't work, as python complains that list indices need to be integers, no tuples. I'm having trouble trying to understand what the line is trying to do. Anyone have any ideas?

Here's some surrounding code, if that helps:

if len(sample) > 2:
    axis = sample[:,0]
    base = numpy.take(sample, [numpy.argmin(axis), numpy.argmax(axis)], axis=0)
    return link(dome(sample, base),
                dome(sample, base[::-1]))
else:
    return sample

(Additionally, I'm not sure what the base[::-1] means, but that at least works.)


axis is a Python list, but it should be a numpy array. The code is using numpy's special indexing rules for arrays to extract the first column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜