Can self.threshold really be anything? It seems to me that a numpy array with a precise shape is excepted. If this is the case, add the test, and raise ValueError if no case fit.