[SciPy-user] issue for 0.2: python2.3 float deprecation warnings ???

Bob Ippolito scipy-user@scipy.net
Tue, 23 Sep 2003 22:16:37 -0400


On Sunday, Sep 21, 2003, at 10:01 America/New_York, Gary Pajer wrote:

> I'm sure you're on to this issue, but I can't find much mention of it:
>
> E.g.:, with python2.3 *only*
>
>>> from scipy import plt
>>> plt.plot((1., 2., 3.))
>
> /usr/local/lib/python2.3/site-packages/wxPython/gdi.py:283:
> DeprecationWarning: integer argument expected, got float
>   self.this = gdic.new_wxColour(*_args,**_kwargs)
> /usr/local/lib/python2.3/site-packages/wxPython/gdi.py:570:
> DeprecationWarning: integer argument expected, got float
>   val = gdic.wxDC_DrawRotatedText(self, *_args, **_kwargs)
> /usr/local/lib/python2.3/site-packages/wxPython/gdi.py:702:
> DeprecationWarning: integer argument expected, got float
>   val = gdic.wxDC_SetClippingRegion(self, *_args, **_kwargs)
>
> these warnings have something to do with a change made in python in 
> going to
> v. 2.3.  I can't tell if the problem is with scipy or wxPython.  I 
> checked
> the wxPython bug tracker and mailing list archive, and it's mentioned 
> there
> with the advice to clean up one's source code.

I think the issue is that anything that loses precision automatically 
is being deprecated in Python, for example:
 >>> 1 / 2
0
 >>> from __future__ import division
 >>> 1 / 2
0.5

 >>> 0xFFFFFFFF
-1
 >>> 0xFFFFFFFF # probably Python 2.4, I don't think there's a 
__future__ for this though
4294967295L

I think the float -> int warning is coming from (at the C API level of 
the extensions you're using) PyArg_ParseTuple(PyObject *args, char 
*format, ...) where the format has an "i" in it but the corresponding 
element of the tuple is a Python float.  I don't think there's a way 
around it, other than making sure your arguments are integers or 
changing all of your C APIs to take C doubles (format string "d") and 
floor/bounds check them yourself.

I think that either way is unfortunate, because it's inconvenient and 
doing either will probably make your code run slower and use more 
memory.  Maybe they should add format characters for the old behavior?  
I guess it's not terribly significant given the overhead of calling 
functions, though.

-bob