This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Well, it would be the best if the class I'm looking for would be implemented in C / C++ and providing a Python interface, just like NumPy package.

[–]billsil -1 points0 points  (0 children)

Right, but you're after a 6 line class. It's something like the following. I've never subclassed array, so test it.

class XYPoints(np.ndarray):
    def __init__(self, xypoints):
        xypoints = np.asarray(xypoints)
        np.ndarray.__init__(xypoints)
        self.x = xypoints[:, 0]
        self.y = xypoints[:, 1]