self.value est un tableau qui ressemble à [189.0, 192.0, 186.0, 184.0, 195.0]
Code
def pics(self):
index = 0
total = len(self.value)
if total < 3:
return "Pas assez de valeurs."
if self.value[0] == self.value[1]:
index = index + 1
elif self.value[index] < self.value[index + 1]:
direction = 1
else :
direction = 0
index = index + 1
text = ""
while index < total:
if direction == 1:
if self.value[index] < self.value[index + 1]:
direction = 1
elif self.value[index] == self.value[index + 1]:
direction = 1
[b]else :[/b]
direction = 0
text = text + '<li><span class=\"picmax\">' + str(self.value[index]) + " le " + str(self.date[index]) + '</span></li>\n'
######################
else :
######################
if self.value[index + 1] < self.value[index]:
direction = 0
elif self.value[index] == self.value[index + 1]:
direction = 0
else :
direction = 1
text = text + '<li><span class=\"picmin\">' + str(self.value[index]) + " le " + str(self.date[index]) + '</span></li>\n'
index = index + 1
return text
index = 0
total = len(self.value)
if total < 3:
return "Pas assez de valeurs."
if self.value[0] == self.value[1]:
index = index + 1
elif self.value[index] < self.value[index + 1]:
direction = 1
else :
direction = 0
index = index + 1
text = ""
while index < total:
if direction == 1:
if self.value[index] < self.value[index + 1]:
direction = 1
elif self.value[index] == self.value[index + 1]:
direction = 1
[b]else :[/b]
direction = 0
text = text + '<li><span class=\"picmax\">' + str(self.value[index]) + " le " + str(self.date[index]) + '</span></li>\n'
######################
else :
######################
if self.value[index + 1] < self.value[index]:
direction = 0
elif self.value[index] == self.value[index + 1]:
direction = 0
else :
direction = 1
text = text + '<li><span class=\"picmin\">' + str(self.value[index]) + " le " + str(self.date[index]) + '</span></li>\n'
index = index + 1
return text
Cette fonction est censée retrouver les pics (hauts et bas) dans le tableau self.value
Il y a un problème, qui semble lié au else mis entre commentaires dans le code.
Il me retourne une exception, point c'est tout. et ca gène assez...
quelqu'un peut me dire ou est l'erreur ?