[Numpy-discussion] numpy.fromiter hiding exceptions

Åsmund Hjulstad asmund.hjulstad at gmail.com
Fri Feb 18 04:20:26 EST 2011

Hi all,

I am finding it hard to debug cases where I am creating numpy arrays from
generators, and the generator function throws an exception. It seems that
numpy just swallows the exception, and what I get is a not too helpful

ValueError: iterator too short

Much more helpfull would be to see the original exception, and get the
stacktrace in ipython (or wherever I am working).

Is this possible in some easy way, or am I stuck with the equivalent of

if debug:
   mygenerator = list(mygenerator)
a = np.fromiter(iter(mygenerator), dtype=xxx, count=xxx)

Åsmund Hjulstad, asmund at hjulstad.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110218/0900c1ec/attachment.html>

More information about the NumPy-Discussion mailing list