From: Jochen <jo...@un...> - 2002-05-06 22:37:43
Attachments:
numarray.diff
|
I am trying to run numarray on Cygwin. (Where Numeric seems to work fine.) In order to compile it I had to change the use of round to rint, as Cygwin's C library (newlib) doesn't have round. The patch is attached. When I use it I don't get far, though: ,---- | > python | Python 2.2 (#1, Dec 31 2001, 15:21:18) | [GCC 2.95.3-5 (cygwin special)] on cygwin | Type "help", "copyright", "credits" or "license" for more information. | >>> import numarray as na | >>> x = na.array([1.0, 2.0]) | >>> x | Traceback (most recent call last): | File "<stdin>", line 1, in ? | File "/usr/lib/python2.2/site-packages/numarray/numarray.py", line 591, in __repr__ | MAX_LINE_WIDTH, PRECISION, SUPPRESS_SMALL, ', ', 1) | File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 86, in array2string | format, item_length = _floatFormat(data, precision, suppress_small) | File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 140, in _floatFormat | non_zero = numarray.abs(numarray.compress(numarray.not_equal(data, 0), data)) | File "/usr/lib/python2.2/site-packages/numarray/ufunc.py", line 474, in __call__ | cfunc, ufargs, scalar) | File "/usr/lib/python2.2/site-packages/numarray/ufunc.py", line 312, in _doit | apply(cfunc, ufargs) | TypeError: 'PyCObject' object is not callable | >>> `---- If I print out the type of cfunc down in _doit, I get (the expected) ,---- | <type 'PyCObject'> `---- Any ideas, probably some hints how to proceed? Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E |
From: Jochen <jo...@un...> - 2002-08-19 22:53:39
|
Hi, I could succesfully compile numarray (see numpy.org) on Cygwin (updated last week), using the standard Cygwin python. However many tests fail, due to "missing" overflow or "division by zero" exceptions. I took a quick look at the test-failures of numarray on numpy. The first problem is that we don't get a "Overflow error" warning when it is expected: ,----[Cygwin] | >>> array([1, 8, 100, 100], type=Int8) * array([1, 8, 100, -100], type=Int8) | array([ 1, 64, 127, -128], type=Int8) `---- Whereas on Linux we get ,----[Linux] | >>> array([1, 8, 100, 100], type=Int8) * array([1, 8, 100, -100], type=Int8) | Warning: Encountered overflow(s) in multiply | array([ 1, 64, 127, -128], type=Int8) `---- Is this related to a configuration option of python (--with-sigfpe ?) or a "feature" of the Cygwin libm/libc? Any ideas? Btw, I tried to rebuild python (cvs maint22-release patched for _socket) but got the following errors with the math module (similar for cmath): ,---- | gcc -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.3.12-i686-2.2/mathmodule.o -L/usr/local/lib -L. -lm -lpython2.2 -o build/lib.cygwin-1.3.12-i686-2.2/math.dll | build/temp.cygwin-1.3.12-i686-2.2/mathmodule.o: In function `math_1': | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:57: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:57: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:57: undefined reference to `PyFPE_jbuf' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:57: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:59: undefined reference to `PyFPE_dummy' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:59: undefined reference to `PyFPE_counter' | build/temp.cygwin-1.3.12-i686-2.2/mathmodule.o: In function `math_2': | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:74: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:74: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:74: undefined reference to `PyFPE_jbuf' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:74: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:76: undefined reference to `PyFPE_dummy' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:76: undefined reference to `PyFPE_counter' | build/temp.cygwin-1.3.12-i686-2.2/mathmodule.o: In function `math_ldexp': | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:173: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:173: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:173: undefined reference to `PyFPE_jbuf' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:173: undefined reference to `PyFPE_counter' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:175: undefined reference to `PyFPE_dummy' | /home/software/programming/compiler/python/dist/src/Modules/mathmodule.c:175: undefined reference to `PyFPE_counter' | collect2: ld returned 1 exit status | WARNING: building of extension "math" failed: command 'gcc' failed with exit status 1 `---- Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E |
From: Todd M. <jm...@st...> - 2002-05-07 12:57:26
|
Jochen Küpper wrote: >I am trying to run numarray on Cygwin. >(Where Numeric seems to work fine.) > >In order to compile it I had to change the use of round to rint, as >Cygwin's C library (newlib) doesn't have round. The patch is >attached. > >When I use it I don't get far, though: >,---- >| > python >| Python 2.2 (#1, Dec 31 2001, 15:21:18) >| [GCC 2.95.3-5 (cygwin special)] on cygwin >| Type "help", "copyright", "credits" or "license" for more information. >| >>> import numarray as na >| >>> x = na.array([1.0, 2.0]) >| >>> x >| Traceback (most recent call last): >| File "<stdin>", line 1, in ? >| File "/usr/lib/python2.2/site-packages/numarray/numarray.py", line 591, in __repr__ >| MAX_LINE_WIDTH, PRECISION, SUPPRESS_SMALL, ', ', 1) >| File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 86, in array2string >| format, item_length = _floatFormat(data, precision, suppress_small) >| File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 140, in _floatFormat >| non_zero = numarray.abs(numarray.compress(numarray.not_equal(data, 0), data)) >| File "/usr/lib/python2.2/site-packages/numarray/ufunc.py", line 474, in __call__ >| cfunc, ufargs, scalar) >| File "/usr/lib/python2.2/site-packages/numarray/ufunc.py", line 312, in _doit >| apply(cfunc, ufargs) >| TypeError: 'PyCObject' object is not callable >| >>> >`---- >If I print out the type of cfunc down in _doit, I get (the expected) >,---- >| <type 'PyCObject'> >`---- > >Any ideas, probably some hints how to proceed? > Hi Jochen, Trying to call a PyCObject is a symptom of an inconsistent installation. Extension functions stopped being passed around as PyCObjects in numarray-0.3. Instead, I created a new C-type called CFunc which binds an "extension function implementation" to the correct generic wrapper. An added benefit was that CFuncs are directly callable as python functions, whereas PyCObjects were not. The repr of a CFunc looks more like: >>> import _ufuncInt32 >>> _ufuncInt32.functionDict[_ufuncInt32.functionDict.keys()[0]] <cfunc 'rshift_Int32_reduce' at 4019ffec check-self:0 align:1 io:(1, 1)> So, it appears that your c-extensions are not yet updated to CFuncs, but your numarray python code is updated to CFuncs. I suggest deleting your numarray installation and re-installing. Todd > >Greetings, >Jochen > > >------------------------------------------------------------------------ > >? Lib/ChangeLog >? Lib/numinclude.py >Index: Include/numarray/ChangeLog >=================================================================== >RCS file: /cvsroot/numpy/numarray/Include/numarray/ChangeLog,v >retrieving revision 1.1 >diff -u -r1.1 ChangeLog >--- Include/numarray/ChangeLog 22 Apr 2002 20:33:16 -0000 1.1 >+++ Include/numarray/ChangeLog 6 May 2002 22:32:43 -0000 >@@ -1,8 +1,18 @@ >+2002-05-06 Jochen Küpper <jo...@un...> >+ >+ * numcomplex.h (NUM_CROUND): Use rint instead of round. The latter is >+ not available on all systems, namely Cygwin. >+ > 2002-04-10 Jochen Küpper <jo...@un...> > > * ndarrayinfo.h: Change NDInfo->strides to NDInfo->stride for > consistency. Adopt all sources accordingly. > >- * genapi.py (bodystring): Do not include emacs' Local Variables >- section into gnerated files. >+ * genapi.py (bodystring): Do not include emacs' Local Variables section >+ into gnerated files. >+ > >+ * Local Variables: >+ * mode: auto-fill >+ * fill-column: 79 >+ * End: >Index: Include/numarray/numcomplex.h >=================================================================== >RCS file: /cvsroot/numpy/numarray/Include/numarray/numcomplex.h,v >retrieving revision 1.5 >diff -u -r1.5 numcomplex.h >--- Include/numarray/numcomplex.h 30 Apr 2002 17:29:43 -0000 1.5 >+++ Include/numarray/numcomplex.h 6 May 2002 22:32:43 -0000 >@@ -228,7 +228,7 @@ > #define NUM_CCEIL(p, s) (s).r = ceil((p).r); (s).i = ceil((p).i); > > #define NUM_CFABS(p, s) (s).r = fabs((p).r); (s).i = fabs((p).i); >-#define NUM_CROUND(p, s) (s).r = round((p).r); (s).i = round((p).i); >+#define NUM_CROUND(p, s) (s).r = rint((p).r); (s).i = rint((p).i); > #define NUM_CHYPOT(p, q, s) { Complex64 t; \ > NUM_CSQR(p, s); NUM_CSQR(q, t); \ > NUM_CADD(s, t, s); \ >Index: Lib/codegenerator.py >=================================================================== >RCS file: /cvsroot/numpy/numarray/Lib/codegenerator.py,v >retrieving revision 1.22 >diff -u -r1.22 codegenerator.py >--- Lib/codegenerator.py 3 May 2002 19:14:06 -0000 1.22 >+++ Lib/codegenerator.py 6 May 2002 22:32:44 -0000 >@@ -1593,7 +1593,7 @@ > ["minimum", 2, 1, (function_td, "ufminimum"), generic_operator_sigs, opt_minmax_decl], > > ["fabs", 1, 1, (function_td, "fabs"), generic_mathfunction_sigs, ""], >-["around", 1, 1, (function_td, "round"), generic_mathfunction_sigs, ""], >+["around", 1, 1, (function_td, "rint"), generic_mathfunction_sigs, ""], > ["hypot", 2, 1, (function_td, "hypot"), generic_mathfunction_sigs, ""], > > # Complex ufuncs >Index: Src/_ufuncBoolmodule.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncBoolmodule.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncBoolmodule.c >--- Src/_ufuncBoolmodule.c 29 Apr 2002 21:39:50 -0000 1.8 >+++ Src/_ufuncBoolmodule.c 6 May 2002 22:32:45 -0000 >@@ -2365,7 +2365,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncFloat32module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncFloat32module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncFloat32module.c >--- Src/_ufuncFloat32module.c 29 Apr 2002 21:39:50 -0000 1.8 >+++ Src/_ufuncFloat32module.c 6 May 2002 22:32:45 -0000 >@@ -1773,7 +1773,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncFloat64module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncFloat64module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncFloat64module.c >--- Src/_ufuncFloat64module.c 29 Apr 2002 21:39:50 -0000 1.8 >+++ Src/_ufuncFloat64module.c 6 May 2002 22:32:45 -0000 >@@ -1773,7 +1773,7 @@ > Float64 *tout = (Float64 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncInt16module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncInt16module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncInt16module.c >--- Src/_ufuncInt16module.c 29 Apr 2002 21:39:51 -0000 1.8 >+++ Src/_ufuncInt16module.c 6 May 2002 22:32:45 -0000 >@@ -2254,7 +2254,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncInt32module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncInt32module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncInt32module.c >--- Src/_ufuncInt32module.c 29 Apr 2002 21:39:51 -0000 1.8 >+++ Src/_ufuncInt32module.c 6 May 2002 22:32:45 -0000 >@@ -2254,7 +2254,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncInt8module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncInt8module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncInt8module.c >--- Src/_ufuncInt8module.c 29 Apr 2002 21:39:51 -0000 1.8 >+++ Src/_ufuncInt8module.c 6 May 2002 22:32:45 -0000 >@@ -2254,7 +2254,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncUInt16module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncUInt16module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncUInt16module.c >--- Src/_ufuncUInt16module.c 29 Apr 2002 21:39:51 -0000 1.8 >+++ Src/_ufuncUInt16module.c 6 May 2002 22:32:45 -0000 >@@ -2249,7 +2249,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } >Index: Src/_ufuncUInt8module.c >=================================================================== >RCS file: /cvsroot/numpy/numarray/Src/_ufuncUInt8module.c,v >retrieving revision 1.8 >diff -u -r1.8 _ufuncUInt8module.c >--- Src/_ufuncUInt8module.c 29 Apr 2002 21:39:51 -0000 1.8 >+++ Src/_ufuncUInt8module.c 6 May 2002 22:32:45 -0000 >@@ -2249,7 +2249,7 @@ > Float32 *tout = (Float32 *) buffers[1]; > > for (i=0; i<niter; i++, tin++, tout++) { >- *tout = round(*tin); >+ *tout = rint(*tin); > } > return 0; > } > > numarray.diff > > Content-Type: > > text/x-patch > Content-Encoding: > > quoted-printable > > -- Todd Miller jm...@st... STSCI / SSG (410) 338 4576 |
From: Jochen <jo...@un...> - 2002-05-07 15:13:50
|
On Tue, 07 May 2002 08:57:00 -0400 Todd Miller wrote: Todd> Jochen K=FCpper wrote: >> I am trying to run numarray on Cygwin. >> (Where Numeric seems to work fine.) >>=20 >> In order to compile it I had to change the use of round to rint, as >> Cygwin's C library (newlib) doesn't have round. The patch is >> attached. Todd> Trying to call a PyCObject is a symptom of an inconsistent Todd> installation. That was easy. I am not sure why a=20 ,---- | python setup.py build --force | python setup.py install --force `---- didn't do it "right" automatically (it definitely /should/), but deleting everyting in site-packages and reinstalling works. The remaining question is how to deal with round: a) Use rint instead of round everywhere. b) We use rint but make sure we are using the correct rounding mode. c) We write our own round function using floor or ceil and use that on Cygwin. d) We use rint on Cygwin, round everywhere else. Greetings, Jochen --=20 University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E |
From: Todd M. <jm...@st...> - 2002-05-07 16:11:34
|
Jochen Küpper wrote: >On Tue, 07 May 2002 08:57:00 -0400 Todd Miller wrote: > >Todd> Jochen Küpper wrote: > >>>I am trying to run numarray on Cygwin. >>>(Where Numeric seems to work fine.) >>> >>>In order to compile it I had to change the use of round to rint, as >>>Cygwin's C library (newlib) doesn't have round. The patch is >>>attached. >>> > >Todd> Trying to call a PyCObject is a symptom of an inconsistent >Todd> installation. > >That was easy. I am not sure why a >,---- >| python setup.py build --force >| python setup.py install --force >`---- >didn't do it "right" automatically (it definitely /should/), but >deleting everyting in site-packages and reinstalling works. > > >The remaining question is how to deal with round: >a) Use rint instead of round everywhere. >b) We use rint but make sure we are using the correct rounding mode. >c) We write our own round function using floor or ceil and use that on > Cygwin. >d) We use rint on Cygwin, round everywhere else. > > >Greetings, >Jochen > I think we should define our own function, based on the definition of around in Numeric. This is most closely related to choice "c", using floor and ceil. It was an oversight to use round. Todd -- Todd Miller jm...@st... STSCI / SSG (410) 338 4576 |