[Numpy-discussion] contributing to numpy
Charles R Harris
charlesr.harris at gmail.com
Wed Apr 17 11:43:40 EDT 2013
On Wed, Apr 17, 2013 at 6:29 AM, andrew giessel <andrew.giessel at gmail.com>wrote:
> First, my apologies if this isn't the right forum for this question- I
> looked for a dev list, but couldn't really find it.
> I have a small method I'd like to contribute to numpy, ideally as a method
> on ndarrays and a general function in the numpy namespace. I found it on a
> stackoverflow thread, and it is a generator that yields slices of a
> multidimensional array over a specified axis, which is convenient for use
> in list comprehensions and loops.
> I've forked the numpy source and am familar with git/pull requests/etc but
> the code base is a bit overwhelming.
> I have 2 questions:
> 1) Is there a document which gives an overview of the numpy source and
> perhaps a tutorial on the best way to add methods/functions?
The closest thing is probably Contributing to Numpy
which I suspect is not what you are looking for. At this point you pretty
much need to dig through the source to see how it is organized. To see how
things like tests/documentation are organized look for existing examples
and also the relevant docs in doc/.
> 2) is there a current way to do this in numpy? The only iterator related
> stuff I found in a brief search last night was for essentially looping over
> all elements of an array, one by one.
I think a function like this would be useful. There are ad-hoc ways to get
the same result but they aren't quite as flexible. A few comments
1) The function would probably best go in numpy/core/numeric.py
2) It will need a docstring
3) It will need tests in numpy/core/tests/test_numeric.py
4) xrange isn't Python 3 compatible, use range instead.
The name isn't very descriptive, maybe iter_over_axis? One possible
generalization would to let axis (axes) be either a number, or a list of
axes. The first being the number of leading axes, the second letting one
choose arbitrary axes.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion