error in loading data into the code
Peter Otten
__peter__ at web.de
Mon Oct 18 13:12:57 EDT 2010
Diez B. Roggisch wrote:
> nakisa <nakisa.nooraee at gmail.com> writes:
>
>> hello , I have started python last week,so maybe my question is a bit
>> stupid.
>> I got this error in my simple python code while trying to load data
>> into the code. I have added this libaraies
>> from pylab import *
>> from scipy import *
>> import matplotlib.mlab as mlab
This is idiomatically written as
from matplotlib import mlab
>> from numpy import *
>> from scipy import optimize
When you (nakisa) use *-imports on large beasts like pylab and scipy you are
likely to encounter name clashes. The behaviour of your program becomes
dependent on the order of imports, and for every name in pylab that you want
to use you have to verify that there isn't an object of the same name in
scipy or numpy. I'd say this is more hassle than the few characters you save
are worth.
>> but get this following error :
>>
>> /usr/lib/pymodules/python2.6/matplotlib/mlab.py:1267:
>> DeprecationWarning: use numpy.loadtxt
>> warnings.warn("use numpy.loadtxt", DeprecationWarning) # 2009/06/13
>>
>> any idea ?
>
> You don't get an error. You get a warning. Crucial difference there. You
> can ignore it. You can even suppress it. But you shouldn't bother, the
> authors of mlab should.
... unless you are invoking matplotlib.mlab.load() in the code you wrote
yourself. In this case follow the advice in the warning and replace it with
numpy.loadtxt().
Peter
More information about the Python-list
mailing list