[Numpy-discussion] What is an empty matrix ?

David Cournapeau david at ar.media.kyoto-u.ac.jp
Wed Jul 4 23:22:50 EDT 2007

John Reid wrote:
> David Cournapeau wrote:
>> Hi,
>>     I was wondering what an empty matrix is, and what it is useful for 
>> (by empty matrix, I mean something created by numpy.matrix([])) ? Using 
>> those crash some functions (see for example scipy ticket #381), and I am 
>> not sure how to fix this bug.
>>     David
> Empty input to an algorithm can often be handled naturally by empty 
> matrices in the implementation. Quite often I find that if I've coded 
> things right, the boundary empty input case is handled naturally in this 
> way. I would prefer that no functions crashed when passed empty matrices.
Well, I think nobody argues that scipy function should crash whatever 
input you give :). The problem is more how to treat them. For example, 
using numpy.linalg.pinv crashes numpy right now, det and fft do not 
work, and norm returns 0. This is seems inconcistent to me. If norm is 
0, why det should not be ? Personally, I would say both should be 
errors, but I don't use empty arrays, so I don't have a good grasp of 
their usefulness.


More information about the NumPy-Discussion mailing list