[SciPy-Dev] fwrap refactor: Emulating f2py array shape handling?
Wed Dec 8 07:57:56 CST 2010
I think f2py behavior is too aggressive as well.
Definitely broadcasting should be supported, but probably not much else.
(mobile phone of)
On Dec 8, 2010, at 7:26 AM, Dag Sverre Seljebotn <email@example.com> wrote:
> In the ongoing fwrap refactor I'm trying hard to emulate f2py
> completely. Still it'd be good to know whether you consider the
> behaviour of f2py a feature or a mis-feature. If the latter, it'd be
> trivial to, e.g., include a flag that would allow people to experiment
> with fwrap vs. f2py behaviour, and change to the former at some point if
> the fwrap refactor is pulled upstream.
> The question is how functions should deal with arrays of a different
> rank than what they expect. Possibilities:
> f2py behaviour: Go to very great lengths to convert array shapes. Assume
> the function to be called wants a 2D array, then:
> - Array of shape (1, 1, 3, 1, 1, 4, 1) is treated as (3, 4) # ignore
> - (1, 1, 3, 1, 5, 6) => (3, 30) # flatten trailing dimensions
> - (3) -> (3, 1) # pad with 1-length dims on right side
> - I think there's more...
> fwrap behaviour: Simply raise exception if the rank and dimension does
> not match.
> My opinion: I think f2py is going too far, and would prefer something
> that is closer to the simpler broadcasting rules of NumPy ("Explicit is
> better than implicit"). Perhaps allow (3,) -> (3, 1), but not the others...
> Dag Sverre
> SciPy-Dev mailing list
More information about the SciPy-Dev