[SciPy-dev] Inconsisten return type from discrete dists.

Otto Tronarp otttr440 at student.liu.se
Sat Jan 25 15:06:36 EST 2003


Hello,

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.

For the first issue I feel that it is more natural for them to return
ints, the attached patch, return_ints.pathc, fixes that.

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)
    else:
        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)?


Regards,
Otto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: missing_check_shape.patch
Type: text/x-patch
Size: 950 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20030125/22625673/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: return_ints.patch
Type: text/x-patch
Size: 668 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20030125/22625673/attachment-0001.bin>


More information about the SciPy-Dev mailing list