[Numpy-discussion] contributing to numpy
Charles R Harris
charlesr.harris@gmail....
Wed Apr 17 10:43:40 CDT 2013
On Wed, Apr 17, 2013 at 6:29 AM, andrew giessel <andrew.giessel@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.
>
> https://gist.github.com/andrewgiessel/5400659
>
> 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
<http://docs.scipy.org/doc/numpy/dev/index.html?highlight=development>,
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.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130417/b1efe16b/attachment.html
More information about the NumPy-Discussion
mailing list