I am trying to make a class a record within a numpy array.
The piece of code I am working on has the following class within it:
class Record:
def __init__(self):
self.count = 0
self.level = 0
self.list = []
self.max = None
self.min = None
def add(self, value):
self.count += 1
self.level += value
if self.max is None:
self.max = value
else:
self.max = max(value, self.max)
if self.min is None:
self.min = value
else:
self.min = min(value, self.min)
self.list.append(value)
when I use this class manually it works as I would expect and does
what I want eg:
x = Record()
x.add(42)
x.add(22)
x.add(342)
x.add(44)
x.add(12)
x.add(2)
for eachitem in x.list:
print eachitem
42
22
342
44
12
2
It's Okay to here.
When I create the following code:
vegetation_matrix = numpy.empty(shape=(x_bins+1,y_bins+1))
for each_line in point_scandata:
matrix_x = round_to_value((each_line[0]-x_offset),horizontal_precision)
matrix_y = round_to_value((each_line[1]-y_offset),horizontal_precision)
vegetation_matrix[matrix_x][matrix_y] = Record()
I get an error:
Traceback (most recent call last):
File "MatrixTo3bynArray.py", line 159, in <module>
vegetation_matrix[matrix_x][matrix_y] = Record()
SystemError: error return without exception set
I would ask the universal what am I doing wrong, but how about I ask
in this particular situation, what am I doing wrong?
Can anybody guide me through this problem?
Regards,
David
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion