kron bug with zero-length dimensions?
Hi, the kron(a,b) function seems to allow shapes such as (0,x) or (y,0) only for the second argument b, not for the first argument a. (See below for examples.) Maybe it's too harsh to call it a bug because the result is typically not defined mathematically. But then why differentiate between allowing those things for b (very useful), but not for a (thus requiring workarounds.) Thanks for your help, Sven
n.kron(n.ones((0,1)), n.ones((1,1))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/numpy/lib/shape_base.py", line 572, in kron result = concatenate(result, axis=axis) ValueError: concatenation of zero-length sequences is impossible n.kron(n.ones((1,0)), n.ones((1,1))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/numpy/lib/shape_base.py", line 572, in kron result = concatenate(result, axis=axis) ValueError: concatenation of zero-length sequences is impossible n.kron(n.ones((1,1)), n.ones((0,1))) array([], shape=(0, 1), dtype=float64) n.kron(n.ones((1,1)), n.ones((1,0))) array([], shape=(1, 0), dtype=float64) n.__version__ '1.0.1'
Sven Schreiber schrieb:
Hi,
the kron(a,b) function seems to allow shapes such as (0,x) or (y,0) only for the second argument b, not for the first argument a. (See below for examples.)
Maybe it's too harsh to call it a bug because the result is typically not defined mathematically. But then why differentiate between allowing those things for b (very useful), but not for a (thus requiring workarounds.)
Well in the meantime I learned several things; for my particular problem matlib.repmat is better suited than kron anyway (note that repmat isn't mentioned yet in the numpy book), and "zero-length dimensions" may not be the accurate term in numpy-speak (would zero-length axis be ok?), however I still haven't learned the reason for kron's partial limitation described above... any insights on this? thanks again, sven
Theres also numpy.tile which is like a repmat generalized to N-dim. --bb On 1/27/07, Sven Schreiber <svetosch@gmx.net> wrote:
Sven Schreiber schrieb:
Hi,
the kron(a,b) function seems to allow shapes such as (0,x) or (y,0) only for the second argument b, not for the first argument a. (See below for examples.)
Maybe it's too harsh to call it a bug because the result is typically not defined mathematically. But then why differentiate between allowing those things for b (very useful), but not for a (thus requiring workarounds.)
Well in the meantime I learned several things;
for my particular problem matlib.repmat is better suited than kron anyway (note that repmat isn't mentioned yet in the numpy book),
and "zero-length dimensions" may not be the accurate term in numpy-speak (would zero-length axis be ok?),
however I still haven't learned the reason for kron's partial limitation described above... any insights on this?
thanks again, sven _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (2)
-
Bill Baxter -
Sven Schreiber