Closed GoogleCodeExporter closed 9 years ago
If I run the g++ command:
g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -fPIC
-I/usr/local/lib/python2.5/site-packages/scipy/weave
-I/usr/local/lib/python2.5/site-packages/scipy/weave/scxx
-I/usr/local/lib/python2.5/site-packages/scipy/weave/blitz
-I/usr/local/lib/python2.5/site-packages/numpy/core/include
-I/usr/local/include/python2.5 -c
/nas/users/u78240/unix/.python25_compiled/sc_7d69cda7fe7d1c8e8e05b7b896c9f8db0.c
pp -o
/tmp/u78240/python25_intermediate/compiler_eea14bca698e73bcb1037b044675db15/nas/
users/u78240/unix/.python25_compiled/sc_7d69cda7fe7d1c8e8e05b7b896c9f8db0.o
I get the following error:
/nas/users/u78240/unix/.python25_compiled/sc_7d69cda7fe7d1c8e8e05b7b896c9f8db0.c
pp: In function 'PyObject* compiled_func(PyObject*, PyObject*)':
/nas/users/u78240/unix/.python25_compiled/sc_7d69cda7fe7d1c8e8e05b7b896c9f8db0.c
pp:745: error: no match for call to '(py::object) (int&)'
Original comment by b...@girorosso.com
on 24 Feb 2012 at 5:59
If I switch to revision 886 check_scenarios runs fine. If I then switch to the
current revision, without cleaning the environment, check_scenarios also runs
fine. Investigating further.
Original comment by b...@girorosso.com
on 24 Feb 2012 at 6:08
Tracked down source of failure to revision 915. Looking to see what changed
here to cause this.
Original comment by b...@girorosso.com
on 26 Feb 2012 at 11:00
As an update on comment 3, this is specifically caused by opening the file
based array as an memmap object. i.e.
def _get_numpy_binary_array(self, name):
"""Return the an memmap object as represented by the .npy file"""
filename = self._array_files.get(name)
if filename is not None:
#return load(filename)
return open_memmap(filename)
If I comment out the call to open_memmap and uncomment the call to load the
problem goes away.
The issue here is that we want to use a memmap object as slice assignment won't
work otherwise. Looking into what we can do to resolve this.
Original comment by b...@girorosso.com
on 26 Feb 2012 at 11:12
The theory is that weave functions do not cope well with memmap objects.
For this particular one, called in
capacity_spectrum_functions.calculate_updated_demand, an memmap object 'TVD' is
derived from the magnitudes vector in the event set.
If I turn this into an in memory array by using asarray, e.g.
TVD = asarray(TVD)
this passes the function successfully (and fails at a different weave function
called later).
This was successful until clean_all.py called as the compiled weave functions
get cached, so the old version was being called. This worked as 'TVD' is a
ndarray-like object.
Original comment by b...@girorosso.com
on 27 Feb 2012 at 12:31
All uses of weave.inline use type_converters=converters.blitz. This does not
contain a converter for numpy.memmap so it defaults to the standard python
object converter. A python object cannot be used in the same way so the
compiler throws the error.
This is resolved by adding to the converters list a custom numpy.memmap
converter that simply subclasses the blitz array converter and assigns
numpy.memmap to the matching types, like so:
class memmap_converter(blitz_spec.array_converter):
def init_info(self):
blitz_spec.array_converter.init_info(self)
self.matching_types = [numpy.memmap]
# Use the blitz converters already used for weave inlines
# and add to start of list so we don't get the catchall
eqrm_converters = [memmap_converter()] + converters.blitz
and in use:
weave.inline(code,
['num_sites','num_events','num_periods',
'Ra','Rv','Rd','R','periods',
'TAV','TVD'],
type_converters=weave_converters.eqrm_converters,
compiler='gcc')
Original comment by b...@girorosso.com
on 27 Feb 2012 at 3:36
The fix described above is implemented in revision 963.
Original comment by b...@girorosso.com
on 27 Feb 2012 at 3:57
Original issue reported on code.google.com by
b...@girorosso.com
on 24 Feb 2012 at 5:28