because it's written as C code using the blitz type converter.. I found the answer to my own problem. I added type_converters = converters.blitz in the ext_functions function call.
On Mon, Nov 17, 2008 at 7:09 PM, Nadav Horesh <[EMAIL PROTECTED]>wrote: > On Mon, 2008-11-17 at 15:42 +0100, Søren Nielsen wrote: > why > test(x,y) = 2; > and not > test[x][y] = 2; > ? > > Nadav > > Can anyone explain why this fails? This piece of code runs perfectly using > weave.inline and type_converters = blitz.. > > Obviously it can't handle 2D arrays anymore. It's just a stupid example to > illustrate that. > > Thanks, > Soren > > CODE : > ------------------------------------------------------------------------------------------------ > > > mod = ext_tools.ext_module('ravg_ext') > > test = zeros((5,5)) > xlen = 5 > ylen = 5 > > code = """ > int x, y; > > for( x = 0; x < xlen; x++) > { > for( y = 0; y < ylen; y++) > { > test(x,y) = 2; > } > } > > """ > > ravg = ext_tools.ext_function('ravg', code, ['xlen', 'ylen', 'test']) > mod.add_function(ravg) > mod.compile(compiler = 'gcc') > > RESULT: > > ------------------------------------------------------------------------------------------------ > C:\Temp\ravg_ext.cpp: In function `PyObject* ravg(PyObject*, PyObject*, > PyObject*)': > C:\Temp\ravg_ext.cpp:654: error: `test' cannot be used as a function > C:\Temp\ravg_ext.cpp:641: warning: unused variable 'Ntest' > C:\Temp\ravg_ext.cpp:642: warning: unused variable 'Stest' > C:\Temp\ravg_ext.cpp:643: warning: unused variable 'Dtest' > > Traceback (most recent call last): > File "C:\Temp\ravg_extension.py", line 132, in ? > build_ravg_extension() > File "C:\Temp\ravg_extension.py", line 125, in build_ravg_extension > mod.compile(compiler = 'gcc') > File "C:\Python24\Lib\site-packages\scipy\weave\ext_tools.py", line 365, > in compile > verbose = verbose, **kw) > File "C:\Python24\Lib\site-packages\scipy\weave\build_tools.py", line > 269, in build_extension > setup(name = module_name, ext_modules = [ext],verbose=verb) > File "C:\Python24\Lib\site-packages\numpy\distutils\core.py", line 184, > in setup > return old_setup(**new_attr) > File "C:\Python24\Lib\distutils\core.py", line 166, in setup > raise SystemExit, "error: " + str(msg) > CompileError: error: Command "g++ -mno-cygwin -O2 -Wall > -IC:\Python24\lib\site-packages\scipy\weave > -IC:\Python24\lib\site-packages\scipy\weave\scxx > -IC:\Python24\lib\site-packages\numpy\core\include -IC:\Python24\include > -IC:\Python24\PC -c C:\Temp\ravg_ext.cpp -o > c:\docume~1\ssn\locals~1\temp\ssn\python24_intermediate\compiler_894ad5ed761bb51736c6d2b7872dc212\Releas > > > _______________________________________________ > Numpy-discussion mailing [EMAIL > PROTECTED]://projects.scipy.org/mailman/listinfo/numpy-discussion > > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion