[Numpy-discussion] What is an empty matrix ?
Thu Jul 5 07:42:34 CDT 2007
David Cournapeau schrieb:
> 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.
First of all I suggest to change terminology from "empty" (because of
the confusion with numpy.empty()) to something like zero-length array.
Such zero-length arrays are useful for generic code, so I agree with
other posters that errors should normally not be raised just because of
Then I would suggest that all functions that return arrays should return
some conformable zero-length array. For example, IMHO
e = np.linalg.inv(np.ones((0,0)))
should return another (0,0)-array (it crashes right now).
For things like sum() or det(), I guess the problem is that such
reduce-like methods return scalars for other good reasons, and therefore
they cannot be zero-length. I don't see a better solution for this
inconsistency except to document this and tell people to watch out; but
maybe the real experts know better!?
just my 2€-ct,
More information about the Numpy-discussion