[SciPy-dev] Inconsisten return type from discrete dists.
oliphant.travis at ieee.org
Sat Jan 25 16:03:12 CST 2003
On Sat, 2003-01-25 at 13:06, Otto Tronarp wrote:
> I started looking on writing some unit tests anyway. While doing that I
> discovered that the return type from discrete distributions where
> inconsistent or rather they all seems to return floats except for
> randint. Further, some of them also returns a array of length 1 when
> called without size argument while others return a simple number.
Great, thanks for looking at this.
> For the first issue I feel that it is more natural for them to return
> ints, the attached patch, return_ints.pathc, fixes that.
Yes, I agree with you.
> For the second issue I think that it is more convenient if they always
> returns an array. I have no patch for that, but I can fix it if that is
> the consensus.
> While I wrote the unit tests I also found more bugs. There seem to be a
> missing function in rv.py, namley _check_shape. By the look of how it's
> used it should do something like this:
> def _check_shape(size):
> if isinstance(size, tuple):
> Ns = reduce(operator.mul, size)
> Ns = size
> return (size, Ns)
> Attached patch, missing_check_shape.patch, fixes that.
> I also have a couple of question on coding guide lines.
> 1 - What is the correct way to check if a array is of integer type?
> 2 - What is the correct way to call things from Numeric? i.e.
> scipy.shape(a) or Numeric.shape(a)?
It's not completely consistent, but I think scipy.shape is better as it
will make a transition to numarray easier if and when that happens.
More information about the Scipy-dev