Permalink
Browse files

Bump version to 0.2.0dev; add a sandbox with an example.

  • Loading branch information...
kwgoodman committed Dec 1, 2010
1 parent 0d43852 commit f7e38237aeca3951ac099101906143a9335babcf
Showing with 105 additions and 6 deletions.
  1. +15 −1 RELEASE.rst
  2. +1 −1 bottleneck/version.py
  3. +35 −4 doc/source/development.rst
  4. +1 −0 sandbox/.gitignore
  5. +28 −0 sandbox/nanmean.pyx
  6. +25 −0 sandbox/setup.py
View
@@ -6,9 +6,23 @@ Release Notes
These are the major changes made in each release. For details of the changes
see the commit log at http://github.com/kwgoodman/bottleneck
-Bottleneck 0.1.0
+Bottleneck 0.2.0
================
+*Release date: Not yet released, in development*
+
+**Enhancements**
+
+- Added a sandbox for prototyping of new Bottleneck functions
+
+Older versions
+==============
+
+Release notes from past releases.
+
+Bottleneck 0.1.0
+----------------
+
*Release date: 2010-12-01*
Preview release of Bottleneck.
View
@@ -1,4 +1,4 @@
"Bottleneck version"
# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z"
-__version__ = "0.1.0"
+__version__ = "0.2.0dev"
View
@@ -5,14 +5,14 @@ Development
There are many ways to help improve Bottleneck:
- Use it and report bugs, typos, suggestions
-- Write a prototype for a new function (that takes a 1d array as input)
+- Write a prototype for a new function in the sandbox
- Work on bits from the roadmap below
- Participate in a sprint!
Step #1: Get the code at https://github.com/kwgoodman/bottleneck
Roadmap
-"""""""
+-------
**0.1**
@@ -26,13 +26,44 @@ Roadmap
to a buffer using strides. See
`here <http://projects.scipy.org/numpy/attachment/ticket/1213/_selectmodule.pyx>`_ for a (non-reducing) example.
- Template the code to make maintance and the expansion to more dtypes
- easier. Two possible approaches, which is better:
+ easier. Three possible approaches, which is the best fit for Bottleneck:
`one <http://mail.scipy.org/pipermail/scipy-user/2010-November/027645.html>`_
- or `two <http://projects.scipy.org/numpy/attachment/ticket/1213/generate_qselect.py>`_?
+ or `two <http://projects.scipy.org/numpy/attachment/ticket/1213/generate_qselect.py>`_ or
+ `three <https://github.com/jsalvatier/cython_ufuncs>`_?
**0.3**
- Add more functions
- What's a good way to find a moving window maximum? Is
`this <http://home.tiac.net/~cri/2001/slidingmin.html>`_ a good way to go?
- What other functions would fit in well with the rest of Bottleneck?
+
+Sandbox
+-------
+
+A good place to try out an idea for a new Bootleneck function is in the
+sandbox directory.
+
+You do not need to make a function that handles every possible dtype and
+an arbitrary number of dimensions. A prototype function need only handle a 1d
+float64 input array. The idea is to concentrate on the algorithm, not dtypes
+or ndim.
+
+The sandbox comes with an example of a nanmean cython function that takes a
+1d float64 NumPy array as input.
+
+To convert nanmean.pyx to a C file and compile it::
+
+ $ cd bottleneck/sandbox
+ bottleneck/sandbox$ python setup.py build_ext --inplace
+ running build_ext
+ cythoning nanmean.pyx to nanmean.c
+ <snip>
+
+To use the the function::
+
+ >>> from nanmean import nanmean
+ >>> import numpy as np
+ >>> a = np.array([1.0, 2.0, 4.0])
+ >>> nanmean(a)
+ 1.1666666666666667
View
@@ -0,0 +1 @@
+*.c
View
@@ -0,0 +1,28 @@
+
+# nanmean sandbox example -----------------------------------------------
+#
+# Convert into C and compile using the setup.py file. See Development
+# section of Bottleneck's manual for an example.
+
+import numpy as np
+cimport numpy as np
+import cython
+
+cdef double NAN = <double> np.nan
+
+@cython.boundscheck(False)
+@cython.wraparound(False)
+def nanmean(np.ndarray[np.float64_t, ndim=1] a):
+ "nanmean of 1d numpy array with dtype=np.float64 along axis=0."
+ cdef Py_ssize_t i
+ cdef int a0 = a.shape[0], count = 0
+ cdef np.float64_t asum = 0, ai
+ for i in range(a0):
+ ai = a[i]
+ if ai == ai:
+ asum += ai
+ count += 1
+ if count > 0:
+ return np.float64(asum / count)
+ else:
+ return np.float64(NAN)
View
@@ -0,0 +1,25 @@
+"""
+Use to convert *.pyx in the Bottleneck sandbox to a C file and compile it.
+
+This setup.py is NOT used to install the Bottleneck package. The Bottleneck
+setup.py file is bottleneck/setup.py
+
+To convert from cython to C:
+
+$ cd bottleneck/sandbox
+$ python setup.py build_ext --inplace
+"""
+
+from distutils.core import setup
+from distutils.extension import Extension
+from Cython.Distutils import build_ext
+import numpy
+
+ext_modules = [Extension("nanmean", ["nanmean.pyx"],
+ include_dirs=[numpy.get_include()])]
+
+setup(
+ name = 'nanmean',
+ cmdclass = {'build_ext': build_ext},
+ ext_modules = ext_modules
+)

0 comments on commit f7e3823

Please sign in to comment.