[SciPy-Dev] Error in scipy.ndimage documentation

moscardi eric.moscardi@sophia.inria...
Fri Sep 10 13:24:40 CDT 2010


Hi Matthieu,

I changed these arguments to the compilation. But the result is not the same as the example, the result matrix is :

>>> a = np.arange(12.).reshape((4, 3))
>>> fnc= example.shift_function(0.5)
>>> print ndimage.geometric_transform(a, fnc)

array([[ 0.,  0.,  0.],
       [ 0.,  0.,  0.],
       [ 0.,  0.,  0.],
       [ 0.,  0.,  0.]])

instead of :

[[ 0.      0.      0.    ]
 [ 0.      1.3625  2.7375]
 [ 0.      4.8125  6.1875]
 [ 0.      8.2625  9.6375]]

If I try with : 

>>> fnc= example.shift_function(0)

The result matrix is :

array([[ -8.32667268e-16,  -8.32667268e-16,  -8.32667268e-16],
       [  3.00000000e+00,   3.00000000e+00,   3.00000000e+00],
       [  6.00000000e+00,   6.00000000e+00,   6.00000000e+00],
       [  9.00000000e+00,   9.00000000e+00,   9.00000000e+00]])

So I think that something is wrong into the _shift_function from the tutorial. 
I think that the output_coordinates argument is not correct...? But maybe I forgot something which is not specify in the tuto...
Any ideas?

Thanks,
Eric



On Sep 10, 2010, at 7:18 PM, Matthieu Brucher wrote:

> Hi,
> 
> The following function is referenced on the scipy.ndimage page
> (http://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#ndimage-ccallbacks)
> :
> 
> static int
> _shift_function(int *output_coordinates, double* input_coordinates,
>                int output_rank, int input_rank, void *callback_data)
> {
>  int ii;
>  /* get the shift from the callback data pointer: */
>  double shift = *(double*)callback_data;
>  /* calculate the coordinates: */
>  for(ii = 0; ii < irank; ii++)
>    icoor[ii] = ocoor[ii] - shift;
>  /* return OK status: */
>  return 1;
> }
> 
> It obviously cannot be compiled (irank ->  input_rank, icoor ->
> input_coordinates, ocoor ->  output_coordinates)
> 
> Matthieu
> -- 
> Information System Engineer, Ph.D.
> Blog: http://matt.eifelle.com
> LinkedIn: http://www.linkedin.com/in/matthieubrucher
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev

Eric MOSCARDI
INRIA - Virtual Plants
CIRAD, Avenue Agropolis
34398 Montpellier Cedex 5, France
04 67 61 58 00 (ask number 60 09)
email : eric.moscardi@sophia.inria.fr


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20100910/a88a157c/attachment.html 


More information about the SciPy-Dev mailing list