Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weave tutorial obsolete ? (Trac #1368) #1893

Closed
Tracked by #7
scipy-gitbot opened this issue Apr 25, 2013 · 1 comment
Closed
Tracked by #7

Weave tutorial obsolete ? (Trac #1368) #1893

scipy-gitbot opened this issue Apr 25, 2013 · 1 comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/1368 on 2011-01-20 by trac user bscipy, assigned to unknown.

==Is the tutorial obsolete...==

This file : http://projects.scipy.org/scipy/browser/trunk/scipy/weave/doc/tutorial.txt 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 scalar_spec).

(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
            inline(code,['new_array','a_2d'],
                   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 work)?

==...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:

NAME
   scipy.weave.numpy_scalar_spec

FILE
   /usr/lib/python2.6/dist-packages/scipy/weave/numpy_scalar_spec.py

MODULE DOCS
   http://docs.python.org/library/scipy.weave.numpy_scalar_spec
...>>

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 :
http://docs.python.org/library/scipy
http://docs.python.org/library/scipy.weave
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 exist

==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?

@person142
Copy link
Member

Closing since weave is no longer a part of SciPy. This issue is now tracked at scipy/weave#7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac
Projects
None yet
Development

No branches or pull requests

2 participants