Logarithmic plotting indicator fail

I'm trying to make some sort of logarithmic plotting indicator. By means of cargo cult programming I arrived at the stuff below which doesn't work. Any ideas on how to fix this? As an aside, can we Try, Except the ValueError that will occur with math.log(0)?

When defining next() in my strategy like below it appears that the indicator first produces a load of nan's although these are said to be floats. I would have expected to see nan's in the prenext() phase but not in the next() phase.

Also when trying to take the logarithm of an indicator with period=1 (that doesn't produce nan's in next()) I still get the same TypeError. I can't see anything wrong with the input file either, snippet below.

You are replacing a line in the lines array, which does nothing. You have to assign to the line

self.lines.logarithm = ...

The former cannot be caught to make lines be bound, the latter can. Hence the source of the NaN values. Although technically a NaN is a float, so it is unclear whether that's your actual problem.

It looks like math.log doesn't like the array it is getting, or actually I think it's getting a list with one float. With your suggested fix (self.lines.logarithm = ...) and a hack like below log plotting now works. This will probably break all other operations that accept a list as input so I would need a new class OperationX or similar for operations that accept a single value only. Thanks for your support!

class OperationN(PeriodN):
'''
Calculates "func" for a given period
Serves as a base for classes that work with a period and can express the
logic in a callable object
Note:
Base classes must provide a "func" attribute which is a callable
Formula:
- line = func(data, period)
'''
def next(self):
self.line[0] = self.func(self.data.get(size=self.p.period))
def once(self, start, end):
dst = self.line.array
src = self.data.array
period = self.p.period
func = self.func
for i in range(start, end):
dst[i] = func(src[i - period + 1: i + 1][0])

Indeed, I hadn't checked math.log and it takes a single value. The rationale behind an iterable is that the operations are done on a period of N values. Even if N=1, you are still working with a period.