numpy histogram 1.1 -> 1.2

Hi,
   while adding the step-histogram I learned about the change of numpy.histogram. As MPL trunk relies in numpy 1.1, I think its a good idea to switch to the new histogram, i.e. use "new=True". Indeed, this is required to be able to allow to give bin-edges, which is possible with MPL 0.91.
   However, while keeping API compatibility on the one hand by allowing to provide bin-edges, this step also breaks API compatibility since the definition of bins has changed:

numpy 1.0.4

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]:histogram(x, bins=array([0,0.1,0.2]))
Out[4]:(array([11, 11, 78]), array([ 0. , 0.1, 0.2]))

numpy 1.1.0.dev5106'

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]: histogram(x, bins=array([0,0.1,0.2]),new=True)
Out[4]: (array([11, 11]), array([ 0. , 0.1, 0.2]))

How should this be handled? Follow numpy, breaking API compatibility and point to the API change of histogram? Or keeping API compatibility with MPL0.91 and write a wrapper function?

I would prefer the first option...

Manuel

Here's the link to the numpy wiki:

http://projects.scipy.org/scipy/numpy/roadmap#Semanticchangeforhistogram

Manuel Metz wrote:

···

Hi,
   while adding the step-histogram I learned about the change of numpy.histogram. As MPL trunk relies in numpy 1.1, I think its a good idea to switch to the new histogram, i.e. use "new=True". Indeed, this is required to be able to allow to give bin-edges, which is possible with MPL 0.91.
   However, while keeping API compatibility on the one hand by allowing to provide bin-edges, this step also breaks API compatibility since the definition of bins has changed:

numpy 1.0.4

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]:histogram(x, bins=array([0,0.1,0.2]))
Out[4]:(array([11, 11, 78]), array([ 0. , 0.1, 0.2]))

numpy 1.1.0.dev5106'

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]: histogram(x, bins=array([0,0.1,0.2]),new=True)
Out[4]: (array([11, 11]), array([ 0. , 0.1, 0.2]))

How should this be handled? Follow numpy, breaking API compatibility and point to the API change of histogram? Or keeping API compatibility with MPL0.91 and write a wrapper function?

I would prefer the first option...

Manuel

Manuel Metz wrote:

Hi,
   while adding the step-histogram I learned about the change of numpy.histogram. As MPL trunk relies in numpy 1.1, I think its a good idea to switch to the new histogram, i.e. use "new=True". Indeed, this is required to be able to allow to give bin-edges, which is possible with MPL 0.91.
   However, while keeping API compatibility on the one hand by allowing to provide bin-edges, this step also breaks API compatibility since the definition of bins has changed:

numpy 1.0.4

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]:histogram(x, bins=array([0,0.1,0.2]))
Out[4]:(array([11, 11, 78]), array([ 0. , 0.1, 0.2]))

numpy 1.1.0.dev5106'

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]: histogram(x, bins=array([0,0.1,0.2]),new=True)
Out[4]: (array([11, 11]), array([ 0. , 0.1, 0.2]))

How should this be handled? Follow numpy, breaking API compatibility and point to the API change of histogram? Or keeping API compatibility with MPL0.91 and write a wrapper function?

I would prefer the first option...

I strongly agree.

Eric

···

Manuel

Eric Firing wrote:

Manuel Metz wrote:

Hi,
   while adding the step-histogram I learned about the change of numpy.histogram. As MPL trunk relies in numpy 1.1, I think its a good idea to switch to the new histogram, i.e. use "new=True". Indeed, this is required to be able to allow to give bin-edges, which is possible with MPL 0.91.
   However, while keeping API compatibility on the one hand by allowing to provide bin-edges, this step also breaks API compatibility since the definition of bins has changed:

numpy 1.0.4

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]:histogram(x, bins=array([0,0.1,0.2]))
Out[4]:(array([11, 11, 78]), array([ 0. , 0.1, 0.2]))

numpy 1.1.0.dev5106'

In [1]:from numpy import *
In [2]:random.seed(18)
In [3]:x = random.random(100)
In [4]: histogram(x, bins=array([0,0.1,0.2]),new=True)
Out[4]: (array([11, 11]), array([ 0. , 0.1, 0.2]))

How should this be handled? Follow numpy, breaking API compatibility and point to the API change of histogram? Or keeping API compatibility with MPL0.91 and write a wrapper function?

I would prefer the first option...

I strongly agree.

Eric

Hi,

so, I just commited the patch and also updated the API_CHANGES file.

Manuel