Skip to content

Commit 74fc718

Browse files
committed
Fix linebuffer get on older Python
1 parent 7d8393e commit 74fc718

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

backtrader/linebuffer.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -468,20 +468,9 @@ def get(self, ago=0, size=1):
468468
# If not using islice, directly slice the array
469469
values = self.array[start:end]
470470
if getattr(values, "typecode", None) == "d":
471-
try:
472-
idx = values.index(INF)
473-
while True:
474-
values[idx] = 0.0
475-
idx = values.index(INF, idx + 1)
476-
except ValueError:
477-
pass
478-
try:
479-
idx = values.index(NEG_INF)
480-
while True:
471+
for idx, value in enumerate(values):
472+
if value in (INF, NEG_INF):
481473
values[idx] = 0.0
482-
idx = values.index(NEG_INF, idx + 1)
483-
except ValueError:
484-
pass
485474
return values
486475

487476
return array.array(

0 commit comments

Comments
 (0)