I have a dictionary
d = {0: array([0, 0], dtype=uint16), 1: array([1, 1], dtype=uint16), 2:
array([2, 2], dtype=uint16), 3: array([3, 3], dtype=uint16)}
or
d = {0:d0,1:d1,2:d2,3:d3}
d0, d1, d2 and d3 are numpy.ndarray type
I wish to get the interleaved data by using
outputdata = numpy.array([item for items in itertools.izip(d.values()) for item
in items])
But I get outputdata = array([[0, 0], [1, 1], [2, 2], [3, 3]],
dtype=uint16)
which is different from the desired answer, which can be obtained by
outputdata = numpy.array([item for items in itertools.izip(d0,d1,d2,d3) for
item in items])
outputdata = array([0, 1, 2, 3, 0, 1, 2, 3], dtype=uint16)
I notice that when outputdata = numpy.array([item for items in
itertools.izip((d0,d1,d2,d3)) for item in items]) is used,
outputdata = array([[0, 0], [1, 1], [2, 2], [3, 3]],
dtype=uint16)
Is there any way to izip over dictionary values d.values() and obtain
outputdata = array([0, 1, 2, 3, 0, 1, 2, 3], dtype=uint16)
I'm stumped a bit by this itertools izip behavior, suggestions appreciated.
~iyer
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel. _______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor