[Tutor] unsupported operand

stm atoc stm.at.oc at googlemail.com
Sun Dec 18 23:35:34 CET 2011


Well, I tried to  check and I do not have that problem any more..but i
have the clear script as follows and a couple of question regarding to
this:

# coding: utf-8
from pylab import *
import numpy
import matplotlib.pyplot as pyplot
import matplotlib.mlab as mlab
#tmax=360

with open("ourtest_out.list", "r") as f:
   t = numpy.array([float(v) for v in f.readline().split()[1:]])

for t, filename in enumerate("ourtest_out.list"):

	a = numpy.loadtxt("ourtest_out.list", skiprows=3)
Conc=[]
#Conc = a[:, 200]
Conc.append(a[:,200])
#Conc = a[0:, tmax+1:]
plot(Conc,t)
show()

My main problem is, i do try to see the plot of Conc according to
time. I have a graph without any data!
Basically, I have a program written in FORTRAN including conc, time,
etc. calculation. The out put data shows that I do have concentration.
However, i am not able to have a plot based on time.
I should mention that I did have run the model (fortran) for
concentration according to the number of layer (N=200) and defined the
concentration like this Conc(0:N). Perhaps the reason that I am not
able to see the concentration with time is because of this definition.
BUT, still if I do plot based on pyplot.pcolor, I have a nice and
seems correct graph.

So, actually, I am not sure what is the problem for showing the
regular/linear plot. I hope I made it clear now..

Would it be possible to give me some hint please?

Thank you in advance,
Sue

On Sun, Dec 18, 2011 at 2:07 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> stm atoc wrote:
>
>> and this is the error that I got:
>
>
> Would you like us to guess which line causes the error?
>
> Please show the ENTIRE traceback. Do not retype it from memory, paraphrase
> or simplify it, or otherwise change it in any way. Copy and paste it.
>
>
>> TypeError: unsupported operand type(s) for -: 'list' and 'int'
>>
>> What would you suggest?
>
>
> The code sample you showed did not include any subtractions. This hints that
> perhaps you are not showing us all of the code you are actually running. The
> full traceback will answer that one way or the other.
>
> Otherwise, I suggest you look at the line which the traceback prints. It
> probably has something like "result = a - b" (or some other subtraction).
> Look for the two variables: one of them is set to a list.
>
>
> --
> Steven
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list