ENH : added bin edges -> bin centers function

 - convince function + test
Should be changed to us the faster method.
On Aug 31, 2014 1:55 PM, "Li" <notifications@github.com> wrote:

> In nsls2/core.py:
>
> > +    Helper function for turning a array of bin edges into
> > +    an array of bin centers
> > +
> > +    Parameters
> > +    ----------
> > +    input_edges : array-like
> > +        N + 1 values which are the left edges of N bins
> > +        and the right edge of the last bin
> > +
> > +    Returns
> > +    -------
> > +    ndarray
> > +        A length N array giving the centers of the bins
> > +    """
> > +    input_edges = np.asarray(input_edges)
> > +    return input_edges[:-1] + np.diff(input_edges) / 2
>
> I know this is a bit picky and boring.
>
> In [366]: a = np.arange(500)
>
> In [367]: timeit (a[:-1]+a[1:])/2
> 100000 loops, best of 3: 14.3 µs per loop
>
> In [368]: timeit (a[:-1]+np.diff(a)/2)
> 10000 loops, best of 3: 26.5 µs per loop
>
> Just a difference between O(n) and O(2n), boring test...
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/NSLS-II/NSLS2/pull/104/files#r16936065>.
>