From: Czerminski, R. <ry...@ar...> - 2000-06-02 15:38:23
|
Is the behaviour illustrated below a bug or the Python's feature ? Python 1.5.2 (#4, Mar 3 2000, 15:04:36) [GCC 2.8.1] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> >>> from math import exp >>> x = -706. >>> while x > -900: ... x = x - 1 ... print 'x, exp(x) = %g %g' % (x, exp(x)) ... x, exp(x) = -707 8.99086e-308 x, exp(x) = -708 3.30755e-308 x, exp(x) = -709 0 [...] x, exp(x) = -745 0 Traceback (innermost last): File "<stdin>", line 3, in ? OverflowError: math range error >>> Ryszard Czerminski phone: (781)994-0479 ArQule, Inc. email:ry...@ar... 19 Presidential Way http://www.arqule.com Woburn, MA 01801 fax: (781)994-0679 -----Original Message----- From: Jean-Bernard Addor [mailto:jb...@ph...] Sent: Friday, June 02, 2000 10:19 AM To: Num...@li... Subject: [Numpy-discussion] Is it a bug ? Hey Numeric people! I am just upgrading to a more recent version of Numeric and observe a new behaviour: Python 1.5.2 (#9, May 30 2000, 15:08:12) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Hello from .pythonrc.py >>> import Numeric >>> Numeric.__version__ '11' >>> Numeric.arange(2)*1j Segmentation fault Python 1.5.1 (#1, Dec 17 1998, 20:58:15) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Hello from .pythonrc.py >>> import Numeric >>> Numeric.__version__ '1.7' >>> Numeric.arange(2)*1j array([ 0.+0.j, 0.+1.j]) I also saw: Numerical Python - Bug Tracking Viewing Open Bugs Bug ID Summary 102277 CFLOAT/DOUBLE_setitem crashes when accessing imag. part Am I hitting that bug? CU Jean-Bernard _______________________________________________ Numpy-discussion mailing list Num...@li... http://lists.sourceforge.net/mailman/listinfo/numpy-discussion |
From: Jon S. <js...@wm...> - 2000-06-02 15:53:11
|
No, it works correctly for me (other Python revision, anyway): Python 1.5.2 (#3, Sep 27 1999, 15:02:20) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from math import * >>> x=-706. >>> while x>-900: ... x=x-1 ... print 'x, exp(x) = %g %g' % (x, exp(x)) ... x, exp(x) = -707 8.99086e-308 x, exp(x) = -708 3.30755e-308 x, exp(x) = -709 1.21678e-308 ..... x, exp(x) = -898 0 x, exp(x) = -899 0 x, exp(x) = -900 0 >>> Jon Saenz. | Tfno: +34 946012470 Depto. Fisica Aplicada II | Fax: +34 944648500 Facultad de Ciencias. \\ Universidad del Pais Vasco \\ Apdo. 644 \\ 48080 - Bilbao \\ SPAIN On Fri, 2 Jun 2000, Czerminski, Ryszard wrote: > > Is the behaviour illustrated below a bug > or the Python's feature ? > > Python 1.5.2 (#4, Mar 3 2000, 15:04:36) [GCC 2.8.1] on irix6 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> > >>> from math import exp > >>> x = -706. > >>> while x > -900: > ... x = x - 1 > ... print 'x, exp(x) = %g %g' % (x, exp(x)) > ... > x, exp(x) = -707 8.99086e-308 > x, exp(x) = -708 3.30755e-308 > x, exp(x) = -709 0 > [...] > x, exp(x) = -745 0 > Traceback (innermost last): > File "<stdin>", line 3, in ? > OverflowError: math range error > >>> > > Ryszard Czerminski phone: (781)994-0479 > ArQule, Inc. email:ry...@ar... > 19 Presidential Way http://www.arqule.com > Woburn, MA 01801 fax: (781)994-0679 > > > -----Original Message----- > From: Jean-Bernard Addor [mailto:jb...@ph...] > Sent: Friday, June 02, 2000 10:19 AM > To: Num...@li... > Subject: [Numpy-discussion] Is it a bug ? > > > Hey Numeric people! > > I am just upgrading to a more recent version of Numeric and observe a new > behaviour: > > Python 1.5.2 (#9, May 30 2000, 15:08:12) [GCC 2.95.2 19991024 (release)] > on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Hello from .pythonrc.py > >>> import Numeric > >>> Numeric.__version__ > '11' > >>> Numeric.arange(2)*1j > Segmentation fault > > Python 1.5.1 (#1, Dec 17 1998, 20:58:15) [GCC 2.7.2.3] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Hello from .pythonrc.py > >>> import Numeric > >>> Numeric.__version__ > '1.7' > >>> Numeric.arange(2)*1j > array([ 0.+0.j, 0.+1.j]) > > I also saw: > Numerical Python - Bug Tracking > Viewing Open Bugs > Bug ID > Summary > 102277 > CFLOAT/DOUBLE_setitem crashes when accessing imag. > part > > Am I hitting that bug? > > CU > > Jean-Bernard > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion > |
From: Charles G W. <cg...@fn...> - 2000-06-02 16:39:24
|
Czerminski, Ryszard writes: > > Is the behaviour illustrated below a bug or the Python's feature ? I don't know why you're posting this to the NumPy discussion list, since the "math" module is part of the standard Python distribution, not NumPy. Anyhow, the differing behaviors people are seeing are just coming from differences in the system math libraries: On Linux (Intel): Python 1.6a2 (#9, May 22 2000, 12:34:51) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> from math import exp >>> x = -706. >>> while x > -900: ... x = x - 1 ... print 'x, exp(x) = %g %g' % (x, exp(x)) ... x, exp(x) = -707 8.99086e-308 x, exp(x) = -708 3.30755e-308 <snip> x, exp(x) = -745 4.94066e-324 x, exp(x) = -746 0 <snip> x, exp(x) = -899 0 x, exp(x) = -900 0 >>> Wheras on Irix (MIPS): Python 1.6a2 (#8, Jun 1 2000, 20:01:55) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> from math import exp >>> x = -706. >>> while x > -900: ... x = x - 1 ... print 'x, exp(x) = %g %g' % (x, exp(x)) ... x, exp(x) = -707 8.99086e-308 x, exp(x) = -708 3.30755e-308 x, exp(x) = -709 0 x, exp(x) = -710 0 <snip> x, exp(x) = -745 0 Traceback (most recent call last): File "<stdin>", line 3, in ? OverflowError: math range error From the Irix man page for exp(3M): The exp functions return HUGE_VAL when the correct value would overflow, and return zero if the correct value would underflow. The -lm and -lmx versions set the value of errno to ERANGE for both underflow and overflow. Since the Python math module sees errno set after the call to exp, it raises an exception. Whereas on Linux, exp(-very big number) simply returns 0 and does not set errno. On the one hand, Python's behavior makes sense because it simply reflects the behavior of the system math libraries. On the other hand, these kinds of differences make it hard to write portable code - you could test on Linux and think everything is OK, then run on IRIX and get exceptions. Maybe that's just the way life is when you are using floating-point math... Tim Peters may have more to say on this topic <exp(-900)wink> |