2.2.6 为Numpy/Scipy做贡献

看一下这篇教程:http://www.euroscipy.org/talk/882

2.2.6.1 为什么

  • “这有个bug?”
  • “我不理解这个要做什么?”
  • “我有这个神器的代码。你要吗?”
  • “我需要帮助!我应该怎么办?”

2.2.6.2 报告bugs

2.2.6.2.1 好的bug报告

Title: numpy.random.permutations fails for non-integer arguments

I'm trying to generate random permutations, using numpy.random.permutations

When calling numpy.random.permutation with non-integer arguments it fails with a cryptic error message::

  1. >>> np.random.permutation(12)
  2. array([ 6, 11, 4, 10, 2, 8, 1, 7, 9, 3, 0, 5])
  3. >>> np.random.permutation(12.)
  4. Traceback (most recent call last):
  5. File "<stdin>", line 1, in <module>
  6. File "mtrand.pyx", line 3311, in mtrand.RandomState.permutation
  7. File "mtrand.pyx", line 3254, in mtrand.RandomState.shuffle
  8. TypeError: len() of unsized object

This also happens with long arguments, and so np.random.permutation(X.shape[0]) where X is an array fails on 64 bit windows (where shape is a tuple of longs).

It would be great if it could cast to integer or at least raise a proper error for non-integer types.

I'm using Numpy 1.4.1, built from the official tarball, on Windows 64 with Visual studio 2008, on Python.org 64-bit Python.

  • 你要做什么?
  • 重现bug的小代码段(如果可能的话)
    • 实际上发生了什么
    • 期望发生什么
  • 平台(Windows / Linux / OSX, 32/64 bits, x86/PPC, …)
  • Numpy/Scipy的版本In [2]:
  1. print np.__version__
  1. 1.9.2

检查下面的文件是你所期望的

In [3]:

  1. print np.__file__
  1. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.pyc

以免你想要旧/损坏的Numpy安装在哪里

如果不确定,试着删除现有的Numpy安装文件,并且重新安装…

2.2.6.3 为文档做贡献

Hi,

I'd like to edit Numpy/Scipy docstrings. My account is XXXXX

Cheers, N. N.

  1. ```
  • 检查一下风格指南:
  • 不要被吓住;要修补一个小事情,就修补它 ```
  • 编辑
    • 编辑源码发送补丁(和bug一样)
    • 向邮件列表抱怨

2.2.6.4 贡献功能

  1. # 克隆numpy仓库
  2. git clone --origin svn http://projects.scipy.org/git/numpy.git numpy
  3. cd numpy
  4. # 创建功能分支
  5. git checkout -b name-of-my-feature-branch svn/trunk
  6. <edit stuff>
  7. git commit -a
  • http://github.com (或者其他地方)创建一个帐号
  • @ Github创建一个新仓库
  • 将你的工作推送到github

In [ ]:

  1. git remote add github git@github:YOURUSERNAME/YOURREPOSITORYNAME.git
  2. git push github name-of-my-feature-branch

2.2.6.5 如何帮助,总体而言

  • 永远欢迎修补bug!
    • 什么让你最恼怒
    • 浏览一下跟踪器
  • 文档工作
  • 在沟通渠道上询问:
    • numpy-discussion列表
    • scipy-dev列表

In [1]:

  1. %matplotlib inline
  2. import numpy as np