Commit a8c500f1 authored by Niels-Oliver Walkowski's avatar Niels-Oliver Walkowski
Browse files

move attributes from Contrast class to subclass

only two for testing reason
subclassing a subcalls of numpy was hard due to the use of __new__ and
__array_finalize__
max recursion errors appear now after multiple use of derive. Do I need
numpy's __del__ method?
parent 515f74d0
......@@ -28,8 +28,6 @@ class Contrast(np.ndarray):
obj._frames = frames
obj._channel = 2
obj._frm_step = 50
obj._bins = 16
obj._threshold = 60000
obj._save = False
return obj
......@@ -46,12 +44,24 @@ class Contrast(np.ndarray):
return np.ndarray.__array_wrap__(self, out_arr, context)
class LightDark(Contrast):
def __init__(self, arg):
super(LightDark, self).__init__()
# subclassing subclass of numpy http://stackoverflow.com/questions/7342637/how-to-subclass-a-subclass-of-numpy-ndarray
# TODO es gibt noch das Problem, dass numpy nach mehreren Berechnungen von drive eine max recursion Warnung ausgiebt, warum? Brauche ich __del__
class VHistStack(Contrast):
def __new__(cls, frames, input_array=None):
obj = Contrast.__new__(cls, frames, input_array)
obj._bins = 16
obj._threshold = 60000
return obj
def __array_finalize__(self, obj):
if obj is None: return
Contrast.__array_finalize__(self, obj)
self._bins = getattr(obj, '_bins', None)
self._threshold = getattr(obj, '_threshold', None)
# TODO jetzt ausschließlich mit self numpy rechnen statt mit contrast_points liste
def hist_vstack(self):
def derive(self):
contrast_points = []
# pwd list sollte in Frames sein und hier nur durchlaufen werden
for frm_nr in range(self._frames.start, self._frames.end, self._frm_step):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment