[NumPy-Tickets] [NumPy] #2054: f2py's handling of strided arrays.
NumPy Trac
numpy-tickets@scipy....
Tue Feb 14 15:25:15 CST 2012
#2054: f2py's handling of strided arrays.
-------------------------+--------------------------------------------------
Reporter: pch | Owner: pearu
Type: enhancement | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.f2py | Version: 1.6.1
Keywords: |
-------------------------+--------------------------------------------------
Comment(by pearu):
At the moment I don't have time to implement/test the strided array
support for f2py.
However, when copying data is not an issue, then below follows a temporary
workaround
of the issue.
1) Wrap the multiply_me Fortran subroutine with f2py as usual. For
example,
{{{
f2py -c -m foo foo.f90
}}}
2) Create the following Python function:
{{{
def multiply_me(a):
import foo
b = a.copy(order='F')
foo.multiply_me(b)
a[:] = b
}}}
and use it instead of foo.multiply_me.
For example:
{{{
>>> def multiply_me(a):
...: import foo
...: b = a.copy(order='F')
...: foo.multiply_me(b)
...: a[:] = b
...:
>>> import numpy as np
>>> a = np.ones((2,4), np.int64)
>>> multiply_me(a[:,1:3])
>>> print a
[[1 2 2 1]
[1 2 2 1]]
}}}
HTH
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2054#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list