[Numpy-discussion] Uninformative Error

T J tjhnson@gmail....
Sun Jan 10 16:11:06 CST 2010


When passing in a list of longs and asking that the dtype be a float
(yes, losing precision), the error message is uninformative whenever
the long is larger than the largest float.

>>> x = 181626642333486640664316511479918087634811756599984861278481913634852446858952226941059178462566942027148832976486383692715763966132465634039844094073670028044755150133224694791817752891901042496950233943249209777416692569138779593594686170807571874640682826295728116325492852625325418526603207268018328608840
>>> array(x, dtype=float)
OverflowError: long int too large to convert to float

>>> array([x], dtype=float)
ValueError: setting an array element with a sequence.

The first error is informative, but the second is not and will occur
anytime one tries to convert a python list containing longs which are
too long.  Is there a way this error message could be made more
helpful?


More information about the NumPy-Discussion mailing list