Hello, I'm running into an unexpected issue in a program I'm writing, and I was hoping someone could provide some clarification for me. I'm trying to subclass numpy.ndarray (basically create a class to handle a 3D grid). When I instantiate a numpy.ndarray, everything works as expected. When I call numpy.ndarray's constructor directly within my subclass, I get a deprecation warning about object.__init__ not taking arguments. Presumably this means that ndarray's __init__ is somehow (for some reason?) calling object's __init__...
This is some sample code: >>> import numpy as np >>> class derived(np.ndarray): ... def __init__(self, stuff): ... np.ndarray.__init__(self, stuff) ... >>> l = derived((2,3)) __main__:3: DeprecationWarning: object.__init__() takes no parameters >>> l derived([[ 8.87744455e+159, 6.42896975e-109, 5.56218818e+180], [ 1.79996515e+219, 2.41625066e+198, 5.15855295e+307]]) >>> Am I doing something blatantly stupid? Is there a better way of going about this? I suppose I could create a normal class and just put the grid points in a ndarray as an attribute to the class, but I would rather subclass ndarray directly (not sure I have a good reason for it, though). Suggestions on what I should do? Thanks! Jason
-- http://mail.python.org/mailman/listinfo/python-list