[Scipy-tickets] [SciPy] #601: weave does not work with numpy arrays of dtype="O"

SciPy scipy-tickets@scipy....
Fri Feb 8 07:17:50 CST 2008

#601: weave does not work with numpy arrays of dtype="O"
 Reporter:  ceball       |       Owner:  somebody
     Type:  defect       |      Status:  new     
 Priority:  normal       |   Milestone:  0.7     
Component:  scipy.weave  |     Version:          
 Severity:  normal       |    Keywords:          
 If you attempt to pass an array of dtype="O" to Weave, you get an error:

 <weave: compiling>
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "test_weave.py", line 74, in __call__
     inline(code, ['some_array'], local_dict=locals())
   File "test_weave.py", line 16, in inline
   File "[weave location]/weave/inline_tools.py", line 333, in inline
   File "[weave location]/weave/inline_tools.py", line 459, in
     verbose=verbose, **kw)
   File "[weave location]/weave/ext_tools.py", line 353, in compile
     kw,file = self.build_kw_and_file(location,kw)
   File "[weave location]/weave/ext_tools.py", line 334, in
     file = self.generate_file(location=location)
   File "[weave location]/weave/ext_tools.py", line 295, in generate_file
     code = self.module_code()
   File "[weave location]/weave/ext_tools.py", line 203, in module_code
   File "[weave location]/weave/ext_tools.py", line 269, in function_code
     all_function_code += func.function_code()
   File "[weave location]/weave/inline_tools.py", line 77, in function_code
     decl_code = indent(self.arg_declaration_code(),4)
   File "[weave location]/weave/inline_tools.py", line 62, in
     for arg in self.arg_specs]
   File "[weave location]/weave/standard_array_spec.py", line 158, in
     res = self.template_vars(inline=inline)
   File "[weave location]/weave/standard_array_spec.py", line 151, in
     res['num_type'] = num_to_c_types[self.var_type]
 KeyError: 'O'

 This is using a copy of weave checked out from SVN:
 URL: http://svn.scipy.org/svn/scipy/trunk/scipy/weave
 Revision: 3809
 Last Changed Rev: 3736
 Last Changed Date: 2007-12-28 06:53:35 +0800 (Fri, 28 Dec 2007)
 Properties Last Updated: 2008-01-09 15:16:42 +0800 (Wed, 09 Jan 2008)
 (and Python 2.5.1 with numpy 1.0.2).

 The following message to SciPy-User gives code you can use to reproduce
 this error:

 The following message to SciPy-Devel gives an attempt at a patch to solve
 the problem:

 The patch certainly fixes the error above, but it is clearly not a
 complete solution because there is still a problem using arrays of objects
 from C code in Weave. The message above also gives code to demonstrate
 this subsequent problem.

 Additionally, there is some C code for iterating through an array of
 objects that works when called from Instant, but that does not work when
 called from Weave (as patched above):

Ticket URL: <http://scipy.org/scipy/scipy/ticket/601>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list