[Numpy-discussion] basearray lives!
Tim Hochberg
tim.hochberg at cox.net
Sun Apr 30 19:33:03 CDT 2006
After a fashion anyway. I implemented the simplest thing that could
possibly work and I've left out some stuff that even I think we need
(docstring, repr and str). Still it exists, ndarray inherits from it and
some stuff seems to work automagically.
>>> import numpy as n
>>> ba = n.basearray([3,3], int, n.arange(9))
>>> ba
<numpy.basearray object at 0x00B29690>
>>> a = asarray(ba)
>>> a
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> a + ba
array([[ 0, 2, 4],
[ 6, 8, 10],
[12, 14, 16]])
>>> isinstance(a, n.basearray)
True
>>> type(ba)
<type 'numpy.basearray'>
>>> type(a)
<type 'numpy.ndarray'>
>>> len(dir(ba))
19
>>> len(dir(a))
156
Travis: should I go ahead and check this into the trunk? It shouldn't
interfear with anything. The only change to ndarray is the tp_base,
which sets up the inheritance.
-tim
More information about the Numpy-discussion
mailing list