ndimage - why is output_type deprecated ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ndimage - why is output_type deprecated ?

Sebastian Haase
Hi,

I have an 3d - image in uint8 pixel format and would like to use
ndimage.gaussian_filter().
The doctring says:
""" .... The intermediate arrays are
    stored in the same data type as the output. Therefore, for output
    types with a limited precision, the results may be imprecise
    because intermediate results may be stored with insufficient
    precision.
"""

Since I don't have an output array allocated a-priory, it would be
convenient if I could specify that I want the output to be of dtype
np.float32.
So I thought about adding a "dtype" argument to the function
definition in filters.py.

However: I found that this function in turn calls
_ni_support._get_output(output, input)
and _ni_support._get_output(output, input)   already had an optional
`output_type` argument,
which however is "deprecated" -- really it causes even a "raise
RuntimeError" (so it's actually already beyond deprecated ....)

Does anyone here know why that was taken out !?

I would like to put it back (just calling it "dtype=None" -- None
meaning "same as input", and ignored [maybe one should raise an
exception !?] if output is specified)

Thanks,
Sebastian Haase
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: ndimage - why is output_type deprecated ?

Zachary Pincus-2
Hello,

You want the 'output' parameter, which either takes a pre-allocated  
array, OR a dtype.

This is a bit confusing, overloaded-API-wise, and there's also a bug  
in (at least) ndimage.zoom with pre-allocated arrays(*). But the  
functionality is there.

Zach

* http://scipy.org/scipy/scipy/ticket/643


On Apr 16, 2008, at 4:23 AM, Sebastian Haase wrote:

> Hi,
>
> I have an 3d - image in uint8 pixel format and would like to use
> ndimage.gaussian_filter().
> The doctring says:
> """ .... The intermediate arrays are
>    stored in the same data type as the output. Therefore, for output
>    types with a limited precision, the results may be imprecise
>    because intermediate results may be stored with insufficient
>    precision.
> """
>
> Since I don't have an output array allocated a-priory, it would be
> convenient if I could specify that I want the output to be of dtype
> np.float32.
> So I thought about adding a "dtype" argument to the function
> definition in filters.py.
>
> However: I found that this function in turn calls
> _ni_support._get_output(output, input)
> and _ni_support._get_output(output, input)   already had an optional
> `output_type` argument,
> which however is "deprecated" -- really it causes even a "raise
> RuntimeError" (so it's actually already beyond deprecated ....)
>
> Does anyone here know why that was taken out !?
>
> I would like to put it back (just calling it "dtype=None" -- None
> meaning "same as input", and ignored [maybe one should raise an
> exception !?] if output is specified)
>
> Thanks,
> Sebastian Haase
> _______________________________________________
> SciPy-user mailing list
> [hidden email]
> http://projects.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: ndimage - why is output_type deprecated ?

Sebastian Haase
On Wed, Apr 16, 2008 at 5:28 PM, Zachary Pincus <[hidden email]> wrote:

> Hello,
>
>  You want the 'output' parameter, which either takes a pre-allocated
>  array, OR a dtype.
>
>  This is a bit confusing, overloaded-API-wise, and there's also a bug
>  in (at least) ndimage.zoom with pre-allocated arrays(*). But the
>  functionality is there.
>
>  Zach
>

Hi Zach,

thanks for the info.
But I have to say, that this is a really non-intuitive overloading.

I would suggest, to use a separate keyword argument like
"dtype" instead.
"dtype"  is used for this already in many other functions like
np.array, np.zeros, np.empty, .....
I would have never guessed -- the doc strings didn't say either ....

Thanks again,
Sebastian Haase
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: ndimage - why is output_type deprecated ?

Zachary Pincus-2
> thanks for the info.
> But I have to say, that this is a really non-intuitive overloading.
>
> I would suggest, to use a separate keyword argument like
> "dtype" instead.
> "dtype"  is used for this already in many other functions like
> np.array, np.zeros, np.empty, .....
> I would have never guessed -- the doc strings didn't say either ....

A ton about ndimage is under-documented, confusing, or slightly  
broken. (Nevertheless, it remains really useful.) Ndimage could really  
use a good API and documentation cleaning, as well as some attention  
from someone who understands the spline-interpolation code internal to  
the interpolators (and can thus fix some of the open bugs on that).  
Unfortunately, that person isn't me...

Maybe we can start by filing various bugs on it, and then organize  
folks who use ndimage to have a doc-day sort of thing.

As to adding a 'dtype' parameter, I guess that the output_type  
parameter has been deprecated long enough that it could be removed,  
and 'dtype' put in its place, and then the overloaded use of 'output'  
be itself deprecated. Hopefully someone more familiar with the API-
breakage/deprecation policy could chime in here.

Zach
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user