[Scipy-tickets] [SciPy] #1368: Weave tutorial obsolete ?

SciPy Trac scipy-tickets@scipy....
Thu Jan 20 03:41:38 CST 2011

#1368: Weave tutorial obsolete ?
 Reporter:  bscipy                                                                                                                                                                 |       Owner:  somebody
     Type:  defect                                                                                                                                                                 |      Status:  new     
 Priority:  normal                                                                                                                                                                 |   Milestone:  0.9.0   
Component:  scipy.weave                                                                                                                                                            |     Version:  0.8.0   
 Keywords:  weave, tutorial, type_factories, scalar_spec, numpy_scalar_spec, blitz, blitz_tools, inline, type mapping, broken links, python's help, numpy, masked array, xxx_spec  |  
 ==Is the tutorial obsolete...==

 This file :
 is in the setup directory of '''Weave''' for '''Scipy 0.8.0''' (also in
 '''Scipy 0.7.0''', I checked) but the code example (see below) don't work
 ('''ImportError: cannot import name blitz_type_factories'''; the same with

 (l. 641)from weave.blitz_tools import blitz_type_factories
         from weave import scalar_spec
         from weave import inline
         def _cast_copy_transpose(type,a_2d):
             assert(len(shape(a_2d)) == 2)
             new_array = zeros(shape(a_2d),type)
             NumPy_type = scalar_spec.NumPy_to_blitz_type_mapping[type]
             code = \
             for(int i = 0;i < _Na_2d[0]; i++)
                 for(int j = 0;  j < _Na_2d[1]; j++)
                     new_array(i,j) = (%s) a_2d(j,i);
             """ % NumPy_type
                    type_factories = blitz_type_factories,compiler='gcc')
             return new_array

 Nowhere in Weave's source code exist strings '' 'scalar_spec' '' and ''
 'blitz_type_factories','' so the corrections are:

 With inline(''l.654''), type_factories has to be corrected with
 '''type_converters''', shape(''l.646'') is in fact '''a_2d.shape''' and to
 replace "blitz_type_factories", the '''blitz''' list, imported from
 '''scipy.weave.converters''' seems to work.

 >>> from scipy.weave.converters import blitz
 >>> blitz
 [(file:: name: no_name), (file:: name: no_name), (file:: name: no_name),
 (file:: name: no_name), (file:: name: no_name), (file:: name: no_name),
 (file:: name: no_name), (file:: name: no_name), (file:: name: no_name),
 (file:: name: no_name), (file:: name: no_name), (file:: name: no_name),
 (file:: name: no_name), (file:: name: no_name), (file:: name: no_name),
 (file:: name: no_name)]

 (strange list, by the way).

 I don't know how to correct the missing '''scalar_spec''' import, but that
 brings a question: is the tutorial obsolete and where can I find an up-to-
 date version, or is Weave (0.8.0) obsolete (and that code is supposed to

 ==...or is Weave obsolete?==

 In the weave directory there are 8 ''factories'':

 - base_spec
 - blitz_spec
 - cpp_namespace_spec
 - c_spec
 - numpy_scalar_spec
 - standard_array_spec
 - swig2_spec
 - vtk_spec

 Python's help for those modules lacks explanations about
 '''NumPy_to_blitz_type_mapping''', but for more informations, this help
 links to the Module Docs, on the official Python website :

 Help on module scipy.weave.numpy_scalar_spec in scipy.weave:




 This link is broken. That seems strange: why would Python delete this doc?

 By the way, Scipy's and Weave's link are broken also :
 and I've found no help about ''numpy_scalar_spec'' on ''Scipy.org'' or on
 this Wiki.

 To end with link problems, SVN link is broken also :

 svn co http://svn.scipy.org/svn/scipy/trunk/Lib/weave weave -> URL doesn't

 ==Bonus question==

 I'm trying to use ''scipy.weave.inline()'' (or
 ''scipy.weave.inline_tools.inline()'', don't know if there is a
 difference) to compute on a masked array ('''numpy.ma.MaskedArray'''). Can
 you tell me which "''factory''" knows how to convert my variable to C?

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

More information about the Scipy-tickets mailing list