From: Francesc A. <fa...@op...> - 2003-02-19 12:05:09
|
Hi, I think it would be useful to provide some range checking in numarray. Fo= r example, right now, you can do: In [24]: a=3Dnumarray.array([1,2],numarray.Int8) In [25]: a[1] =3D 256 In [26]: a Out[26]: array([1, 0], type=3DInt8) and nothing happens. But I'm proposing to raise an OverflowWarning so tha= t people can be aware of such range overflows. Maybe it is desirable that the default would be to not issue the warning, except when the user wanted to know about that. So, my proposal is that the actual behaviour should be mantained, but whe= n you want to be aware of all the warnings something like this could happen= : In [28]: warnings.resetwarnings() In [29]: a=3Dnumarray.array([1,2],numarray.Int8) In [30]: a[1] =3D 256 OverflowWarning: value assignment not in the type range In [31]: a Out[31]: array([1, 0], type=3DInt8) But perhaps this feature might slow a bit the performance of assignments. Regards, --=20 Francesc Alted `` We are shaped by our thoughts, we become what we think. When the mind is pure, joy follows like a shadow that never leaves. '' -- Buddha, The Dhammapada |