[SciPy-Dev] fwrap refactor: Emulating f2py array shape handling?

Travis Oliphant oliphant at enthought.com
Wed Dec 8 08:57:56 EST 2010


I think f2py behavior is too aggressive as well.

Definitely broadcasting should be supported, but probably not much else.

Travis 

--
(mobile phone of)
Travis Oliphant
Enthought, Inc.
1-512-536-1057
http://www.enthought.com

On Dec 8, 2010, at 7:26 AM, Dag Sverre Seljebotn <dagss at student.matnat.uio.no> 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-length
>  - (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
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev



More information about the SciPy-Dev mailing list